One option is to use a Literal in each place where you need to inject JavaScript. In code-behind, on each page load clear the content of each literal, and then check the step of the user and re-inject the required JS. This keeps literals clean and avoids JS code persisting across postbacks where it might not be needed.
Another option depending on how many JS scripts you have is to put each one in a placeholder, then show/hide that placeholder as required.