timer = setTimeout("changeImage()", 10000);

i = 0;

function changeImage() {
  ++i;
  if (i >= images.length) {
    i = 1;
  }

  $("#categories").animate({ opacity: 0.5 }, "fast", function() {
    $("#categories").css("background-image", "none");
    $("#categories").css("background-image", "url(" + images[i] + ")");
  });
  $("#categories").animate({ opacity: 1 }, "slow");
  
  timer = setTimeout("changeImage()", 10000);
}
