How can I change this footer.php code to call a random image on reload?

  1. That theme should not be using the $ alias as WordPress loads
    jQuery in “No Conflict” mode.
  2. I can only assume the theme is loading its own jQuery, which is
    pretty bad form.
  3. The theme should really be registering and enqueuing the
    script properly rather than just shoving code into the footer.

However, all other things equal and if your images are named numerically, then changing this:

var imgPath="/wp-content/themes/nexus/img/page-headers/<?php echo $name; ?>/1.jpg";

To this:

var imgPath = <?php echo site_url(); ?>/wp-content/themes/nexus/img/page-headers/<?php echo $name; ?>/<?php echo rand(1,5); ?>.jpg';

And it should echo images 1.jpg through 5.jpg randomly.