I've succeeded in doing exactly what I needed. I had to read tons of threads in order to, eventually, figure out that what I needed was a combination of 2 threads. Following is the result of this thread and (finally finding) the one other I needed.
Each category in the site has different images displayed at the top of the page (as per the client's desire). Each product_id for the specific category displays the same images as the parent category. The JavaScript displays a random order of unlimited images each time the page is refreshed or when moving to another page.
To make it work, all js is in 2 php files. The 2 php files making it work are:
/includes/modules/pages/index/jscript_index.php (optional name jscript_whatever.php)
/includes/modules/pages/product_info/jscript_main.php (it "must" be this php page)
Both files must have "matching" code:
<?php
if ($cPath >= 66 and $cPath <= 126) {
?>
<script type="text/javascript" language="javascript">
...your javascript goes here....
</script>
<?php } ?>
The $cPath (in this example) points to one specific category that has multiple sub-categories and products. The statement says if the category is equal to or greater than 66, and is equal to or less than 126, then display the following code.
The exact same/matching script is placed in the jscript_main.php page.
jscript_whatever.php controls categories and sub-categories.
jscript_main.php controls all the product_id pages.
Each of the "calls" or declarations (snippet above) contain the specific category number (i.e. ($cPath== 75) for a single category).
This particular site/project has 7 top categories. Each category must have the (above) code addressing that category number. So, both php files have 7 "calls", or copies of the code (above) with the category number changed and the JavaScript inside the code as you need.
If you place the code in the files as described and only include some of your categories, "all" of the categories will be effected. Declarations must be included to address each category and/or product_id. It's a "once you start you have to finish" operation.
This may have been simple for a php programmer, but for those of us who are doing something similar and don't code php very well (or at all), this thread should shed some light on current or future projects.