while none of these "examples" really even address the issue that PHP cannot do what was originally asked alone, the use of any *srand (srand, mt_srand) function calls are unneeded as of PHP 4.2. PHP will automatically seed the random number generator for you.

furthermore, I'd suggest not posting random pieces of code if you're not entirely sure what that code is actually doing. in Justa's case, you have some JavaScript that creates image objects -- these objects are never actually used, and instead you're simply changing the source value of the 'main' image (which would be the easiest way to do it anyway).