// Number of images
ImgCount = 20;

// Array IMG aanmaken
img = new Array (ImgCount * 3);

// Object Afbeelding
function Afbeelding (id, location, src)  {
	this.id = id;
	this.location = location;
	this.src = src;
	
	this.img = new Image();
	this.img.src = this.src;
}

// Create images
function CreateImg (location)  {
	for (i = 1; i <= ImgCount; i++)  {
		img[location + i] = new Afbeelding(location + i, location, "../../../../gfx/layout/img/" + location + i + ".jpg");
		// alert(img[location + i].src);
	}
}

// RandomPicker
function RandomImg (location)  {
	RandomNumber = Math.ceil(Math.random() * ImgCount);
	document.images["anim" + location].src = img[location + RandomNumber].img.src;
}

// Random Timeout
function RandomTimeA () {
	RandomTime = Math.ceil(Math.random() * 3000) + 1000;
	toA1 = setTimeout('RandomImg("a")', RandomTime);
	toA2 = setTimeout('RandomTimeA()', RandomTime);
}
function RandomTimeB () {
	RandomTime = Math.ceil(Math.random() * 3000) + 1000;
	toB1 = setTimeout('RandomImg("b")', RandomTime);
	toB2 = setTimeout('RandomTimeB()', RandomTime);
}
function RandomTimeC () {
	RandomTime = Math.ceil(Math.random() * 3000) + 1000;
	toC1 = setTimeout('RandomImg("c")', RandomTime);
	toC2 = setTimeout('RandomTimeC()', RandomTime);
}

// Loader
function Load()  {
	CreateImg ("a");
	CreateImg ("b");
	CreateImg ("c");
	
	RandomTimeA();
	RandomTimeB();
	RandomTimeC();
}