OK, that makes it easy.
You would use a simplified version of the smart bg code, eliminating the verification of the image file and just setting the variable $smart_image to the top category id if on a product page.
PHP Code:
<?php //Smart Backgrounds
$smart_image = '';
if ($current_page_base == 'index' or $current_page_base == 'product_info') { //add _ and top cat id to js filename
$smart_image = '_' . (int)$_GET[cPath];
} // /Smart Backgrounds?>
<script src="http://zencart-demo-store2.littleolemedesigns.net/includes/templates/Romance_Divine_Custom/jscript/Header_Animation<?php echo $smart_image;?>.js"></script>
I'm not certain the php inclusion in the script code will work as is; it may be necessary to formulate the script code in php and then output it. If it doesn't work as shown, let me know and I'll work on that.
You will have to be responsible for ensuring that there is a .js file for each top category, and one for the home and all other pages. Name them like
Header_Animation.js
for the home page, and
Header_Animation_23.js
for category 23 and its subs.