Anything that is even slightly complex, simply make it a function and put it in an external JavaScript source file that can be used over and over. HeadSpace , home of Beatnik software, has done just that. Developers just need to load the supplied external script source and make calls to the external functions from within their script. There's nothing more boring than having the same jingle blare through your multimedia speakers over and over again. That is enough to drive even your most ardent supporters away from your site.
Images are also prime candidates for randomization.
Restrict your selection to small images. Pay particular attention to the script that allows you to continue playing music even through page changes. Netscape's DevEdge Online Web site includes a JavaScript reference manual. The site includes many of the basic scripts you will need as well as several useful demos. This is a little more complex than the above example.