Hi everybody,

so I tried to add a spoiler button code to my invisionboard. All things goes well, but when I want to make a reply and click on the spoiler button, it won't popup. So all my visitors have to write out the "spoiler" tag manually. I want it to popup.
Can anyone check this script out and help me?

Code:
<script type='text/javascript'>
var show_spoil = function (ele, e) {
if (e.preventDefault) {
e.preventDefault();
} else {
e.returnValue = false;
}

var j = ele.nextSibling;
if (j.style.display === 'none') {
j.style.display = 'block';
} else {
j.style.display = 'none';
}
};

(function () {
var b = document.getElementsByTagName('div'), c = b.length;
while (c--) {
if (b[c].className.indexOf('postcolor') !== -1 && b[c].innerHTML.indexOf('[spoiler') !== -1) {
b[c].innerHTML = b[c].innerHTML.replace(/\[spoiler(?:=(.+?))?\](.+?)\[\/spoiler\]/gim, function (total, title, inside) {
return "<input type='button' value='" + (title || "Spoiler") + "' class='forminput spoil_button' onclick='show_spoil(this, event)' /><span style='display:none'><hr />" +
inside + "</span>";
});
}
}
})();
</script>

<script type='text/javascript'>
var insert_spoiler = function () {
document.forms['REPLIER'].Post.value += "";
};

(function () {
if (location.href.indexOf('act=Post') !== -1) {
var b = document.getElementsByTagName('input'), c = b.length;
while (c--) {
if (b[c].className === 'codebuttons' && b[c].name === 'LIST') {
/* Why must the DOM be so clunky? */
var i = document.createElement('input');
i.onclick = 'insert_spoiler';
i.value = 'Spoiler'
i.className = 'codebuttons';
i.type = 'button';
i.style.marginLeft = '4px';
b[c].parentNode.insertBefore(i, b[c].nextSibling);
break;
}
}
}
})();
</script>