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

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

 button.addLink("term_Jeeprep6.html","New","../afb/HA/C40650.jpg");
 button.addLink("term_Nissanrep3.html","New","../afb/HA/C52475.jpg");
 button.addLink("term_Nissanrep3.html","New","../afb/HA/72025.jpg");
 button.addLink("term_Nissanrep2.html","New","../afb/HA/72032.jpg");
 button.addLink("term_Nissanrep3.html","New","../afb/HA/72070.jpg");
 button.addLink("term_LandRoverrep09.html","New","../afb/HA/H5093.jpg");
 button.addLink("term_LandRoverrep09.html","New","../afb/BL/LRDF1H.jpg");
 button.addLink("term_LandRoverrep09.html","New","../afb/BL/LRDF2H.jpg");
 button.addLink("term_LandRoverrep12.html","New","../afb/BL/LRY99H.jpg");
 button.addLink("term_RangeRoverrep05.html","New","../afb/BL/RR01PH.jpg");
 button.addLink("term_Nissanrep3.html","New","../afb/ET/23154.jpg");
 button.addLink("term_Toyotarep.html","New","../afb/ET/23667.jpg");
 button.addLink("term_GMCrepm3.html","New","../afb/BL/SA186.jpg");
 button.addLink("term_Jeeprepm.html","New","../afb/BL/SA186.jpg");
 button.addLink("term_Chevroletrepm3.html","New","../afb/BL/SA186.jpg");
 button.addLink("term_LandRover.html","New","../afb/PP/03341.jpg");
 button.addLink("term_RangeRover.html","New","../afb/PP/03341.jpg");
 button.addLink("term_LandRoverrep13.html","New","../afb/BL/LRF2WH.jpg");
 button.addLink("term_LandRoverrep10.html","New","../afb/BL/LRDYAW.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(); }

