// little javascript 
// Total Active Media - AMSTERDAM
// Remy Blom - 4 April 2007

// class randomPictures

randomPictures.prototype._imageUrl;
randomPictures.prototype._imageExt;
randomPictures.prototype._images = new Array();;
randomPictures.prototype._max;

function randomPictures(max)
{
    this._max = max;
    this._imageUrl = "/gfx/randomPics";
    this._imageExt = "jpg";
    
    this.populateArray();
}

randomPictures.prototype.populateArray = function()
{
	for (i=0;i<this._max;i++)
	{
		this._images[i] = this._imageUrl + "/" + (i+1) + "." + this._imageExt;
	}	
}

randomPictures.prototype.getRandomPicture = function()
{
	myIndex = Math.floor(Math.random()*this._images.length);
	this.writeImg(this._images[myIndex]);
	this.removeIndex(myIndex);
}

randomPictures.prototype.writeImg = function(src)
{
    document.write('<img src="' + src + '" />');
}

randomPictures.prototype.removeIndex = function(index)
{
	lastBit = this._images.slice(index+1);
	this._images.splice(index,this._images.length);
	this._images = this._images.concat(lastBit);
}
