// JavaScript Document
// YouTube UBBC for Posts by Chris
// http://studiozero.proboards44.com/index.cgi?board=codes&action=display&thread=1152134544
// Do not redistribute without permisison of the creator

// YouTube UBBC for Posts by Chris
// Do not redistribute without permisison of the creator
// YouTube UBBC for Posts by Chris
// Do not redistribute without permisison of the creator

var perPage = 3; // How many YouTube videos per page. I suggest a limit below 3, as there are dialup users out there.
var ubbcURL = "http://img472.imageshack.us/img472/9892/yuotubeubbc8oa.png"; // URL of the YouTube UBBC image

// No need to edit
var aTD = document.getElementsByTagName("TD");
var curr = 0;
if(location.href.match(/action=display/i)){
for(a=0;a<aTD.length && curr < perPage;a++){
if(aTD[a].colSpan == 3 && aTD[a].vAlign == "top" && aTD[a].firstChild.nodeName.match(/^(#text|hr)$/i) && aTD[a].innerHTML.match(/\[yt\](.+?)\[\/yt\]/gi)){
curr = curr+parseInt(aTD[a].innerHTML.match(/\[yt\](.+?)\[\/yt\]/gi).length);
aTD[a].innerHTML = aTD[a].innerHTML.replace(/\[yt\](.+?)\[\/yt\]/gi,'<object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/$1"></param><embed src="http://www.youtube.com/v/$1" type="application/x-shockwave-flash" width="425" height="350"></embed></object>');
}
}
} else if(document.postForm){
if(location.href.match(/quote=/i)){
var m = document.postForm.message;
m.value = m.value.replace(/\[yt\].+?\[\/yt\]/gi,"");
}
if(document.postForm.color){
var h = document.createElement("span");
h.innerHTML = "<a href='javascript:add(\"[yt]\",\"[/yt]\");'><img src='"+ubbcURL+"' border='0' alt='YouTube' /></a>";
document.postForm.color.parentNode.appendChild(h);
}
}
