function homeOnload ()
{
  cca.registerObject(new AnimatedObject(0, "wiezijnwijChild", new Array(0,1,0,1,0), 400));
  cca.registerObject(new AnimatedObject(0, "belonsChild", new Array(0,2,0,2,0,2,0,1,0), 400));
  cca.registerObject(new AnimatedObject(0, "chatChild2", new Array(0,1,0,1,0,1,0), 300));
  cca.registerObject(new AnimatedObject(0, "chatChild1", new Array(0,2,0,2,0,1,0), 300));
  cca.registerObject(new AnimatedObject(0, "klaagmuurChild", new Array(0,1,0,1,0), 500));
  cca.registerObject(new AnimatedObject(0, "gedichtenChild1", new Array(0,1,0,2,0,2,0,1,0), 300));
  cca.registerObject(new AnimatedObject(0, "gedichtenChild2", new Array(0,1,0,1,0,2,0), 400));
  cca.registerObject(new AnimatedObject(0, "droomkasteelChild", new Array(0,1,0,1,0), 400));
  cca.registerObject(new AnimatedObject(0, "helpelkaarChild", new Array(0,1,0,1,0), 400));
  cca.registerObject(new AnimatedObject(0, "vragenkastChild", new Array(0,1,0,2,0), 400));
  cca.init()

  homeCloudAnim();
}

function ClassChangeAnimator() 
{
  this.objectsArray = new Array();
  this.CLASSPREFIX = "ani";
}

ClassChangeAnimator.prototype =
{
  init : function ()
  {
    var secondsB4 = getRandomInt(6,8);
    setTimeout("cca.animateObject()", (secondsB4*1000))
  },
  
  registerObject : function(object)
  {
    this.objectsArray.push(object)
  },
  
  getRandomObject : function()
  {
    var objectArrayPos = Math.floor(Math.random()*this.objectsArray.length)
    return this.objectsArray[objectArrayPos];
  },
  
  animateObject : function()
  {
    this.animatedObject = this.getRandomObject();
    this.stateNumber = 1;
    setTimeout("cca.changeObjectClass()", this.animatedObject.timePerFrame)
  },
  
  changeObjectClass : function()
  {
    var el = document.getElementById(this.animatedObject.ElementId);
    if (el)
    {
      if (this.animatedObject.sequence[this.stateNumber] >= 0)
      {
        //set the state
        this.currentState = this.animatedObject.sequence[this.stateNumber];
        this.stateNumber++;
        
        //animate
        if (!this.lastState)
           Spif.ClassNameAbstraction.add(el, this.CLASSPREFIX+this.currentState);
        else
          Spif.ClassNameAbstraction.replace(el, this.CLASSPREFIX+this.lastState, this.CLASSPREFIX+this.currentState);
    
        //call next ani
        this.lastState = this.currentState;
        setTimeout("cca.changeObjectClass()", this.animatedObject.timePerFrame)
      }
      else
      {
        //clean up
        Spif.ClassNameAbstraction.remove(el, this.CLASSPREFIX+this.lastState);
        
        //next
        this.init();
      }
    }
  }
}

var cca = new ClassChangeAnimator();




