var Animatie = new Class(
{
    initialize : function()
    {
        this.initializeAnimaties();        
        this.animatiecounter = 0;
    },

    initializeAnimaties :function()
    {
       this.animaties = new Array();
       var bla = $('.animatie');
       for( i = 0; i < bla.length; i++)
       {
           var temp = new AnimatieObject($(bla[i]));
           this.animaties.push(temp);
           $(bla[i]).hide();
       }

       bla = $('.anim_bar');
       for( i = 0; i < bla.length; i++)
       {
           this.animaties[i].overlay = $(bla[i]);
           $(bla[i]).hide();
       }

       bla = $('.blok_bottom_segment');
       for( i = 0; i < bla.length; i++)
       {
           this.animaties[i].text = $(bla[i]);
           //$(bla[i]).hide();
       }

       this.animaties[0].show();
    },

    //initializeTekst :function()
    //{
    //   this.teksten = new Array();
    //   var bla = $('.anim_bar');
    //   for( i = 0; i < bla.length; i++)
    //   {
    //       var temp = $(bla[i]);
    //       this.teksten.push(temp);
    //       temp.hide();
    //   }

    //   this.teksten[0].show();
    //},

    loop : function( interval )
    {        
        //this.intervalid = setInterval(  function (blaat){blaat.animatieLoop();}, interval, this );
        var t = this;
        this.intervalid = setInterval(  function() {t.animatieLoop();}, interval );

    },

    cancelLoop : function()
    {
        clearInterval(this.intervalid);
    },

    animatieLoop : function ()
    {
        var hider = this.animaties[ this.animatiecounter ];
        var shower = this.animaties[ this.loopNumber( this.animatiecounter+1,  this.animaties.length  ) ] ;

        this.animatiecounter = this.loopNumber( this.animatiecounter+1, this.animaties.length );
        this.switchAnimaties( hider, shower );
    },

    //tekstLoop : function ()
    //{
    //    var hider = this.teksten[ this.animatiecounter ];
    //    var shower = this.teksten[ this.loopNumber( this.animatiecounter+1,  this.teksten.length  ) ] ;

    //    this.switchAnimaties( hider, shower );
    //},

    switchTo : function ( anim )
    {
        var hider = this.animaties[ this.animatiecounter ];
        var shower = this.animaties[ anim ] ;
        this.switchAnimaties( hider, shower );

        this.animatiecounter = anim;
    },

    switchAnimaties : function ( hider, shower )
    {
        hider.hide();
        shower.show();
        //$(hider).fadeOut(3000);
        //$(shower).fadeIn(3000);
    },
    loopNumber : function ( number, max )
    {        
        if( number >= max )
            number -= max;
        return number;
    }
});


$(document).ready(
    function()
    {
        anim = new Animatie();
        anim.loop(5000);
    }
)
