/*
** Site24 CMS - www.site24.de
**
** CVS: $Id: javascript.js,v 1.8 2006/10/02 08:12:42 arne Exp $
*/


/* Class RandomImages selects random images from a given set of images */
function RandomImages() {
	var baseDirectory = "";
	var images = new Array();

	this.setBaseDirectory = function(directory) {
		baseDirectory = directory;
	}

	this.add = function(filename, width, height) {
		images[images.length] = new Image(filename, width, height);
	}

	this.getRandomImages = function(num) {
		var display = new Array();
		while (display.length < Math.min(num, images.length)) {
			var random = Math.floor(Math.random() * images.length);
			var image = images[random];
			var duplicate = false;
			for (var index = 0; index < display.length; index++) {
				if (image == display[index]) {
					duplicate = true;
					break;
				}
			}
			if (!duplicate) {
				display[display.length] = image;
			}
		}
		var html = "";
		for (var index = 0; index < display.length; index++) {
			var image = display[index];
			html += "<img alt=\"\" height=\"" + image.height + "\" src=\"" + baseDirectory + image.url + "\" width=\"" + image.width + "\" />";
		}
		return html;
	}

	var Image = function(url, width, height) {
		this.url = url;
		this.width = width;
		this.height = height;
	}
}


/* Add images to be placed and choose some of them randomly */
var images = new RandomImages();
images.setBaseDirectory("resource/layout/images/");
images.add("instrument-1.gif", 70, 100);
images.add("instrument-2.gif", 55, 100);
images.add("instrument-3.gif", 75, 100);
images.add("instrument-4.gif", 45, 100);
images.add("instrument-5.gif", 75, 100);
images.add("instrument-6.gif", 85, 100);
images.add("instrument-7.gif", 65, 100);
images.add("instrument-8.gif", 75, 100);
images.add("instrument-9.gif", 60, 100);
images.add("instrument-10.gif", 80, 100);
images.add("instrument-11.gif", 50, 100);
images.add("instrument-12.gif", 55, 100);
document.write(images.getRandomImages(4));