

// Homepage random image
function randImg() {

	/** array of images */
	this._images = new Array();
	
	/** adds an image to this._images
	  * @param string Image src
	  */
	this.add = function(src) {
		//this._images.push(src);
		this._images[this._images.length] = src;
	}
	
	/** outputs an <IMG> tag, with one random image from this._images 
	  * the image output is removed from queue
	  * @param string class name for <IMG> tag; "randImg" by default
	  * @return string the content of the HTML
	  */
	this.render = function(className) {
		if (!this._images.length) return null;
		if (!className) className = "randImg";
		
		// choose one at random
		var r = Math.round(Math.random() * (this._images.length-1));
		var html = '<img src="' + this._images[r] + '" class="' + className + '" />';
		
		// remove random photo from array
		var n = new Array();
		for (var i=0; i<this._images.length; i++) {
			if (i != r) n[n.length] = this._images[i];
		}
		this._images = n;
		return html;
	}
}