You can use the autoloader system to load the proper javascripts where you want them, without touching any existing files.
First, don't save your js files like
/includes/templates/theme407/js/mhgallery.js
In the general case where you want them loaded every time, save them like
/includes/templates/theme407/jscript/jscript_mhgallery.js
For your particular case where you only want them loaded on certain ez-pages, you need a helper file to do the testing. Then (since you *don't* want them autoloaded) you might name the js files in a way that will be bypassed by the auto system, say keeping your original names.
includes/templates/theme407/jscript/mhgallery.js
Make a new helper file in this folder:
/includes/modules/pages/page/jscript_mhgallery.php
with content like
PHP Code:
<?php
//load these js files for this set of ez-pages
if ($_GET['id'] == '5' or $_GET['id'] == '15' or $_GET['id'] == 9 or $_GET['id'] == '16') {
echo '<script type="text/javascript" src="includes/templates/theme407/jscript/mhgallery.js"></script>
<script type="text/javascript" src="includes/templates/theme407/jscript/initgallerytvframing.js"></script>
<script type="text/javascript" src="includes/templates/theme407/jscript/initgallerystandard.js"></script>';
}
//EOF
I haven't done exactly this before, so if it doesn't work the first time, let me know and we'll tweak it.
Note: you had a typo in your original code that would mess up - no space after 9 here:
$_GET['id'] == 9or $_GET['id'] ==