/**
 * Changes an image from an array of srcs
 *
 * publishes 'randomized' event with index and item (if items array provided)
 *
 * @author Alec Hill
 */
(function(){

com.alechill.RandomizedImage = new Class({
    
	Extends: com.alechill.Randomizer,
	
	Implements: [Events, Options],
	
	options: {
		interval: 0
	},
	
	el: null,
    
    initialize: function(el, images_array, options){
		this.el = $(el);
		this.setOptions(options);
		this.options.items = images_array || [];
		// listen to own 'randomized' event
		this.addEvent('randomized', this.onRandomized.bindWithEvent(this));
		this.parent(options);
    },
	
	/**
	 * change the image
	 */
	onRandomized: function(e, index, item){
		this.el.set('src', item);
	}
    
});

})();