// 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_terrep');

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

button.addLink('term_Chevyrep4.html', 'New', '../afb/HA/38040.jpg');
button.addLink('term_Chevyrep4.html', 'New', '../afb/HA/24067.jpg');
button.addLink('term_Chevyrepm3.html', 'New', '../afb/BL/SA156.jpg');
button.addLink('term_FordUSArepm2.html', 'New', '../afb/BL/SA162.jpg');
button.addLink('term_FordUSArepm2.html', 'New', '../afb/BL/SA155.jpg');
button.addLink('term_GMCrep4.html', 'New', '../afb/HA/24067.jpg');
button.addLink('term_GMCrepm3.html', 'New', '../afb/BL/SA156.jpg');
button.addLink('term_Jeeprep.html', 'New', '../afb/HA/H4933.jpg');
button.addLink('term_LandRovrep08.html', 'New', '../afb/BL/LRDF1H.jpg');
button.addLink('term_LandRovrep08.html', 'New', '../afb/BL/LRDF2H.jpg');
button.addLink('term_LandRovrep10.html', 'New', '../afb/BL/LRDYAW.jpg');
button.addLink('term_LandRovrep12.html', 'New', '../afb/BL/LR99PH.jpg');
button.addLink('term_LandRovrep12.html', 'New', '../afb/BL/LRY99H.jpg');
button.addLink('term_LandRovrep13.html', 'New', '../afb/BL/LRF2WH.jpg');
button.addLink('term_LandRovrep19.html', 'New', '../afb/BL/RR01PH.jpg');
button.addLink('term_LandRovrep19.html', 'New', '../afb/BL/RR95HH.jpg');
button.addLink('term_Nissanrep3.html', 'New', '../afb/HA/72032.jpg');
button.addLink('term_Toyotarep5.html', 'New', '../afb/HA/92079.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(); }
