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

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

 button.addLink("milg_alg02.html","New","../afb/ET/23099.jpg");
 button.addLink("milh_ww2.html","New","../afb/ET/23639.jpg");
 button.addLink("milh_ww2.html","New","../afb/ET/23640.jpg");
 button.addLink("milg_alg.html","New","../afb/ET/23646.jpg");
 button.addLink("mill_F.html","New","../afb/ET/24053.jpg");
 button.addLink("milv_D3.html","New","../afb/HA/H4931.jpg");
 button.addLink("milh_ww1.html","New","../afb/HA/H5136.jpg");
 button.addLink("milv_EDR.html","New","../afb/PP/03294.jpg");
 button.addLink("milv_DB.html","New","../afb/PP/03295.jpg");
 button.addLink("milv_D4.html","New","../afb/PP/03296.jpg");
 button.addLink("milv_D4.html","New","../afb/PP/03363.jpg");
 button.addLink("milg_alg03.html","New","../afb/PP/03372.jpg");
 button.addLink("milv_EDR.html","New","../afb/PP/03289.jpg");
 button.addLink("milv_D4.html","New","../afb/PP/03291.jpg");
 button.addLink("milv_D4.html","New","../afb/PP/03359.jpg");
 button.addLink("milv_DB.html","New","../afb/PP/03360.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(); }

