function ImageCycler( directory, imgId, aId )
{
		this.dir = directory;
		this.imgId = imgId;
		this.aId = aId;
		this.images = new Array();
		this.alts = new Array();
		if ( aId != null ) this.links = new Array();
}


ImageCycler.prototype.addimage = function( name, alt, link )
{
		this.images[ this.images.length ] = name;
		this.alts[ this.alts.length ] = alt;
		if ( this.aId != null ) this.links[ this.links.length ] = link;
}


ImageCycler.prototype.pickimage = function()
{
		var index = Math.floor( ( this.images.length )
						* Math.random() - 0.001 );
		if ( index < 0 ) index = 0;
		var src = this.dir + "/" + this.images[ index ];
		var alt = this.alts[ index ];
		if ( alt == null ) alt = "";

		var img = document.getElementById( this.imgId );
		img.src = src;
		img.alt = alt;
		if ( this.aId != null )
		{
				var link = document.getElementById( this.aId );
				var href = this.links[ index ];
				if ( href != null ) link.href = href;
		}
}


