The problem is with
PHP Code:
collapse_tcat$vbcollapse[collapseimg_$collapseid].gif
That's the line it doesn't like (Thank god for Zend IDE and it's error checking

)
Try changing it to
PHP Code:
collapse_tcat " . $vbcollapse['collapseimg_' . $collapseid] . ".gif
You'll need to do a simaler thing a few lines down as well:
PHP Code:
$vbcollapse[collapseobj_$collapseid]
// to...
$vbcollapse['collapseobj_' . $collapseid]
Disclaimer: This is untested code, so it may or may not work, but it fixes the error about the ]
Thanks,
Alan.