$(document).ready(function() {
  preload_images = new Array();
  i = 0;
  $('#nav li:not(li.active)').each(function(){
    preload_off_image = $(this).find('img').attr('src');
    preload_on_image = preload_off_image.replace('.png', '-active.png');
    preload_images[i] = $('<img>').attr('src', preload_on_image);
    i++;
  });
  $('#nav li:not(li.active)').hover(
    function() {
      off_image = $(this).find('img').attr('src');
      // account for the possibility that it got stuck on
      if (off_image.indexOf('-active.png') != -1) on_image = off_image;
      else on_image = off_image.replace('.png', '-active.png');
      $(this).find('img').attr('src', on_image);
      $(this).addClass('hover');
    },
    function() {
      on_image = $(this).find('img').attr('src');
      off_image = on_image.replace('-active.png', '.png');
      $(this).find('img').attr('src', off_image);
      $(this).removeClass('hover');
    }
  );
});

