var RandomBackgroundImage = {

  /* base path */
  base: "/html-assets/background_images/",

  /* Array of strings: image file names */
  images: [],

  /* init array of images */
  init: function(images) {
    this.images = images;
  },

  /* switch to next image randomly */
  next: function() {
    if(!this.images || this.images.length == 0){
       $$("body")[0].setStyle({backgroundColor: "black"});
      return;
    }

    var index = Math.floor( Math.random() * this.images.length );
    var name = this.base + this.images[index];

    $$("body")[0].setStyle({backgroundImage: "url("+name+")",  backgroundRepeat: "no-repeat"});
  }
}

