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

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

 button.addLink("bestm_GMCrep.html","New","../afb/HA/C28643.jpg");
 button.addLink("bestm_Chevroletrep.html","New","../afb/HA/C28643.jpg");
 button.addLink("bestm_Peugeot.html","New","../afb/ET/22982.jpg");
 button.addLink("bestm_FordUSArep.html","New","../afb/HA/36094.jpg");
 button.addLink("bestm_Vw.html","New","../afb/HA/H5067.jpg");
 button.addLink("bestm_MercedesBenzrep4.html","New","../afb/HA/4902.jpg");
 button.addLink("bestm_Fordrep2.html","New","../afb/HA/4903.jpg");
 button.addLink("bestm_Nissanrep.html","New","../afb/HA/5551.jpg");
 button.addLink("bestm_Renaultrep4.html","New","../afb/HA/5551.jpg");
 button.addLink("bestm_Opelrep.html","New","../afb/HA/5552.jpg");
 button.addLink("bestm_Vwrep05.html","New","../afb/ET/8478.jpg");
 button.addLink("bestm_Vwrep09.html","New","../afb/ET/22528.jpg");
 button.addLink("bestm_Peugeotrep6.html","New","../afb/ET/23783.jpg");
 button.addLink("bestm_Chevroletrepm3.html","New","../afb/BL/SA186.jpg");
 button.addLink("bestm_GMCrepm3.html","New","../afb/BL/SA186.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(); }

