Well I'm afraid in such a complex case I can only really help you debug if I can see the code in action... so the best would be if you extract the relevant bits and set up a fiddle. Trying to hone down the issue like this often helps a lot finding the bug already.
BTW I just noticed another error in your code; the double quotes in the second last line are not supposed to be escaped, only when they are themselves within a quoted string. So it should be
var cmdx = 'document.all.' + slID + ".style.visibility='visible';";
Which leads me to another question... are there by chance any errors in the console?
PS: I'll be AFK now, but I'll have another look tomorrow (unless of course someone else chimes in until then).
PPS: Yes sure, a link would be fine too!