{
      animating = true;
      make_pause('play_pause');
      animate();
    }
  }

  function sliderdrag() {
    if(animating) {
      toggleplaypause();
    }
    var prog = document.getElementById('slider').value
    animationTime = (prog*0.01 * numframes())*(dt * 1000);
    update_time();
  }

  function index() {
    if(animation == null) return null;
    if(dt == 0) return null;
    var i = Math.floor((animationTime * 0.001)/dt);
    var len = numframes();
    if (i==len) {
      return len - 1;
   