var npAnimateTimer = 0;
var npImageNum     = 1;

// Explode the image then load the next
function npIntroAnimate() {
  $("#introImg").effect("explode", {}, "2000", npIntroNext);
}

// Load next image then wait a bit
function npIntroNext() {
  npImageNum++;
  if (npImageNum > 6) {
    $("#introImg").html("<img src='images/intro_movie_02A7.png' />").show("slow").click(replay);
    return;
  }
  npImage = "images/intro_movie_02A"+npImageNum+".png";
  $("#introImg").html("<img src='"+npImage+"' />").show("slow", npWaitExplode);
}

// Wait a bit, then explode the image
function npWaitExplode() {
  npAnimateTimer = setTimeout(npIntroAnimate, 4*1000);
}

function replay() {
  npImageNum = 1;
  npIntroAnimate();
}

$(document).ready( function() {
  // Preload images
  if (document.images) {
    img1 = new Image(336,380); img1.src="images/intro_movie_02A1.png";
    img2 = new Image(336,380); img2.src="images/intro_movie_02A2.png";
    img3 = new Image(336,380); img3.src="images/intro_movie_02A3.png";
    img4 = new Image(336,380); img4.src="images/intro_movie_02A4.png";
    img5 = new Image(336,380); img5.src="images/intro_movie_02A5.png";
    img6 = new Image(336,380); img6.src="images/intro_movie_02A6.png";
    img7 = new Image(336,380); img7.src="images/intro_movie_02A7.png";
  }

  npAnimateTimer = setTimeout(npIntroAnimate, 4*1000);
} );
