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

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

 button.addLink("motm_BMWrep02.html","New","../afb/PP/22807.jpg");
 button.addLink("motm_Ducatirep2.html","New","../afb/PP/22809.jpg");
 button.addLink("motmtv_Hondarep.html","New","../afb/TP/M215.jpg");
 button.addLink("motm_Yamaharep26.html","New","../afb/TP/M282.jpg");
 button.addLink("motm_Yamaharep28.html","New","../afb/TP/M283.jpg");
 button.addLink("motm_HarleyDavidsonrep5.html","New","../afb/TP/M4272.jpg");
 button.addLink("mott_rest.html","New","../afb/ET/23645.jpg");
 button.addLink("mott_tuning.html","New","../afb/ET/24021.jpg");
 button.addLink("motmtv_Yamaharep4.html","New","../afb/HA/2899.jpg");
 button.addLink("motm_Hondarep29.html","New","../afb/HA/4908.jpg");
 button.addLink("motmsc_Suzukirep.html","New","../afb/HA/4909.jpg");
 button.addLink("motm_Yamaharep24.html","New","../afb/HA/4910.jpg");
 button.addLink("motm_Kawasakirep12.html","New","../afb/HA/4913.jpg");
 button.addLink("motm_Yamaharep33.html","New","../afb/HA/5543.jpg");
 button.addLink("motm_Hondarep34.html","New","../afb/HA/4899.jpg");
 button.addLink("motm_Hondarep39.html","New","../afb/HA/4899.jpg");
 button.addLink("motm_Hondarep15.html","New","../afb/ET/23140.jpg");
 button.addLink("motmsc_Piaggiorep3.html","New","../afb/ET/23668.jpg");
 button.addLink("motm_Suzukirep16.html","New","../afb/ET/23668.jpg");
 button.addLink("motmsc_MBKrep.html","New","../afb/ET/23669.jpg");
 button.addLink("motmsc_Yamaharep.html","New","../afb/ET/23669.jpg");
 button.addLink("motm_Triumphrep3.html","New","../afb/ET/23669.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(); }

