// 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_bus2.html","New","../afb/ET/24041.jpg");
 button.addLink("truck_bus2.html","New","../afb/HA/H4938.jpg");
 button.addLink("truckm_Unimog.html","New","../afb/PP/03319.jpg");
 button.addLink("truckm_DAFrep.html","New","../afb/ET/23077.jpg");
 button.addLink("truckm_MercedesBenzrep.html","New","../afb/ET/23784.jpg");
 button.addLink("truckm_FordUSA.html","New","../afb/BL/G10345.jpg");
 button.addLink("truckl_USA.html","New","../afb/BL/G10365.jpg");
 button.addLink("truck_bus3.html","New","../afb/BL/G10366.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(); }

