window.addEvent('domready', function() {
  
  var SplashShow = new Class({
    
      initialize: function(divId) {
          this.show = $(divId);
          this.pictures = this.show.getChildren('.slides').getChildren('li')[0];
          // console.log(this.pictures);
          this.pictureIndex = 0;
          
          this.hideAllImages();
          this.showFirstImage();
          this.fadeNextImage.periodical(10000, this);
      },
      
      hideAllImages: function() {
        this.pictures.each(function(picture){
          picture.fade('hide');
        });
      },
      
      showFirstImage: function() {
        var first = this.pictures[0];
        first.fade('hide');
        first.fade('in');
      },
      
      
      fadeNextImage: function() {
        var current = this.pictures[this.pictureIndex];
        var next = this.pictures[this.nextIndex()];
        
        
        current.fade('out');
        next.fade('in');
        
        this.pictureIndex = this.nextIndex();
      },
      
      nextIndex: function() {
        if (this.pictureIndex + 1 >= this.pictures.length) {
          return 0;
        } else {
          return this.pictureIndex + 1;
        }
      }
      
      
  });
  
  splash = new SplashShow('splashshow_pics');
  splash2 = new SplashShow('splashshow_text');
  
  
  
  
  
  // var splashshow = $('splashshow');
  //   var pictures = splashshow.getChildren('#pictures');
  //   
  //   pictures.each(function(picture) {
  //     
  //   });
  //   
  //   function fadeNextImage(pics) {
  //     
  //   }
  //   
  //   console.log(pictures);
  // alert("splashing");
});
