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

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

 button.addLink("yachtwsm_Yamaha.html","New","../afb/TP/W807.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(); }

