

var generator = function (image_set, output_element, horizontalAlignment, verticalAlignment, prob) {
  this.images = image_set;
  this.output = output_element;

  var w = output_element.width();
  var h = output_element.height();

  for (var x = 0; x < w; x++) {
    var rnd = Math.floor(Math.random() * prob);
    if (rnd == 0) {
      var img = $('<img src="img/' + this.rndImage() + '" />');
      var properties = { };
      
      if(horizontalAlignment)
        properties[horizontalAlignment] = x + "px";
     

      var rndh = Math.floor(Math.random() * h); 
      if(verticalAlignment)
        properties[verticalAlignment] = rndh + "px";      
      
      img.css(properties);
      
      output_element.append(img);
      x += 50;
    }
  }
}

generator.prototype.generate = function () {

}

generator.prototype.rndImage = function () {
  var rnd = this.lastRnd;
  while (rnd == this.lastRnd)
	rnd = Math.floor(Math.random() * this.images.length);
  this.lastRnd = rnd;
  return this.images[rnd];
}

generator.prototype.calibrate = function () {

}

