> All I need now is to figure out the syntax of moving my > script over into a separate .js file instead of being inline.
Instead of a separate .js, why not use an #include that would pull in the javascript code dynamically and resolve the variables for you? I've done this to build javascript on the fly when needed.