var dark = new Image();
var light = new Image();
var angle = 0;
var angle2 = 0;
var cnt1 = 0;
var cnt2 = 0;
var ctx, ctx2, timerId1, timerId2;

function init2() {
  dark.src = 'IMAGES/rotator.gif';
  light.src = 'IMAGES/rotator2.gif';
  ctx = document.getElementById('canvas').getContext('2d');
  ctx2 = document.getElementById('canvas2').getContext('2d');
  //setTimeout ( "spurt1()",500);
  //setInterval(spurt1,5000);
}

function spurt1() {
  spurt2();
  timerId1 = setInterval(drawlight,70);
}

function spurt2() {
  timerId2 = setInterval(drawdark,70);
}

function drawlight() {
  cnt1 += 1;
  angle2 -= .015;
  ctx2.clearRect(0,0,600,600);
  ctx2.save();
  ctx2.translate(300,300);
  ctx2.rotate(angle2);
  ctx2.drawImage(light, -1 * 300, -1 * 300);
  ctx2.restore(); 
  if (cnt1 == 20) { clearTimeout(timerId1); cnt1 = 0; }
  //setTimeout( "spurt2()",500); 
}

function drawdark() {
  cnt2 += 1;
  angle += .015;
  ctx.clearRect(0,0,600,600);
  ctx.save();
  ctx.translate(300,300);
  ctx.rotate(angle);
  ctx.drawImage(dark, -1 * 300, -1 * 300);
  ctx.restore();
  if (cnt2 == 20) { clearTimeout(timerId2); cnt2 = 0; }
}