Your main problem is the way you're calling the DisplayRandomImage() method. As you've written it, PHP will interpret it as a string instead of a method call. Try doing something like this:
background=\"" . $images[DisplayRandomImage()] . "\">\n");
You could also add a $count parameter to the DisplayRandomImage() method's argument list and get rid of that ugly global call. You'd then change
background=\"" . $images[DisplayRandomImage()] . "\">\n");
to
background=\"" . $images[DisplayRandomImage(count($images))] . "\">\n");
and
if (count($images) > 0) {
to
if ($count > 0) {
Other than the method call problem, your logic looks sounds. HTH.
geoff