// RIL1.0 :: Random image link
// ***********************************************
// DOM scripting by brothercake -- http://www.brothercake.com/
// Original concept by Andy Clarke -- http://www.stuffandnonsense.co.uk/
// Create element and attributes based on a method by beetle -- http://www.peterbailey.net/
// Modified by TMB
//************************************************

function randomImageLink() {

var button = new imageLink('rdm_truck');

//add possibilities ('href', 'title text', 'src', 'width', 'height', 'alt text')

button.addLink('truck_alg.html', 'New', '../afb/ET/22458.jpg');
button.addLink('truck_alg2.html', 'New', '../afb/ET/22421.jpg');
button.addLink('truck_bouw.html', 'New', '../afb/ET/22406.jpg');
button.addLink('truck_brand.html', 'New', '../afb/PP/03030.jpg');
button.addLink('truck_brand.html', 'New', '../afb/PP/03033.jpg');
button.addLink('truck_bus.html', 'New', '../afb/PP/03037.jpg');
button.addLink('truckl_DDR.html', 'New', '../afb/PP/03032.jpg');
button.addLink('truckl_DDR2.html', 'New', '../afb/PP/03071.jpg');


button.selectLink();
};

function imageLink(linkid)
{
	//set link object
	this.link = document.getElementById(linkid);

	//create an empty array of possible links
	this.possibles = [];
};

imageLink.prototype.addLink = function()
{
	//store arguments in possible links array
	this.possibles[this.possibles.length] = arguments;
};

imageLink.prototype.selectLink = function()
{
	if(this.link != null)
	{

		this.rnd = this.possibles[Math.floor(Math.random() * this.possibles.length)];
		this.link.href = this.rnd[0];
		this.link.title = this.rnd[1];
		this.img = this.link.getElementsByTagName('img')[0];
		if(this.img != null)
		{
			this.img.src = this.rnd[2];
		}
	}
};

if(typeof document.getElementById != 'undefined') { randomImageLink(); }
