// 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/
//************************************************
//open initialisation function
function randomImageLink() { 
//************************************************



/*****************************************************************************
 Define image links
*****************************************************************************/
// BANNER - NO RESOURCES
//identify an image link ('link-id')
var banner2 = new imageLink('udm-noresources-banner');

//add possibilities ('href', 'title text', 'src', 'width', 'height', 'alt text')
banner2.addLink('http://www.makaton.org/about/stories.htm', 'Living with Makaton', 'https://www.makaton.org/images/banner/banner-adam-matthews.gif', '400', '200', 'Adam Matthews: Living with Makaton');
banner2.addLink('http://www.makaton.org/about/stories.htm', 'Living with Makaton', 'https://www.makaton.org/images/banner/banner-amelia-marsland.jpg', '400', '200', 'Amelia Marsland: Living with Makaton');
banner2.addLink('http://www.makaton.org/about/stories.htm', 'Living with Makaton', 'https://www.makaton.org/images/banner/banner-cameron-maytham.gif', '400', '200', 'Cameron Maytham: Living with Makaton');
banner2.addLink('http://www.makaton.org/about/stories.htm', 'Living with Makaton', 'https://www.makaton.org/images/banner/banner-daniel-jackson.gif', '400', '200', 'Daniel Jackson: Living with Makaton');
banner2.addLink('http://www.makaton.org/about/stories.htm', 'Living with Makaton', 'https://www.makaton.org/images/banner/banner-declan-gilmurray.gif', '400', '200', 'Declan Gilmurray: Living with Makaton');
banner2.addLink('http://www.makaton.org/about/stories.htm', 'Living with Makaton', 'https://www.makaton.org/images/banner/banner-jack-isaacs.jpg', '400', '200', 'Jack Isaacs: Living with Makaton');
banner2.addLink('http://www.makaton.org/about/stories.htm', 'Living with Makaton', 'https://www.makaton.org/images/banner/banner-jacob-devine.jpg', '400', '200', 'Jacob Devine: Living with Makaton');
banner2.addLink('http://www.makaton.org/about/stories.htm', 'Living with Makaton', 'https://www.makaton.org/images/banner/banner-james-farrah.jpg', '400', '200', 'James Farrah: Living with Makaton');
banner2.addLink('http://www.makaton.org/about/stories.htm', 'Living with Makaton', 'https://www.makaton.org/images/banner/banner-james-ledger.gif', '400', '200', 'James Ledger: Living with Makaton');
banner2.addLink('http://www.makaton.org/about/stories.htm', 'Living with Makaton', 'https://www.makaton.org/images/banner/banner-joshua-baker.jpg', '400', '200', 'Joshua Baker: Living with Makaton');
banner2.addLink('http://www.makaton.org/about/stories.htm', 'Living with Makaton', 'https://www.makaton.org/images/banner/banner-liam-shephard.jpg', '400', '200', 'Liam Shephard: Living with Makaton');
banner2.addLink('http://www.makaton.org/about/stories.htm', 'Living with Makaton', 'https://www.makaton.org/images/banner/banner-luca-torrens.jpg', '400', '200', 'Luca Torrens: Living with Makaton');
banner2.addLink('http://www.makaton.org/about/stories.htm', 'Living with Makaton', 'https://www.makaton.org/images/banner/banner-makenzie-shilling.jpg', '400', '200', 'Makenzie Shilling: Living with Makaton');
banner2.addLink('http://www.makaton.org/about/stories.htm', 'Living with Makaton', 'https://www.makaton.org/images/banner/banner-mei-yang-bourne.jpg', '400', '200', 'Mei Yang Bourne: Living with Makaton');
banner2.addLink('http://www.makaton.org/about/stories.htm', 'Living with Makaton', 'https://www.makaton.org/images/banner/banner-melissa-adams.jpg', '400', '200', 'Melissa Adams: Living with Makaton');
banner2.addLink('http://www.makaton.org/about/stories.htm', 'Living with Makaton', 'https://www.makaton.org/images/banner/banner-molly-obrien.jpg', '400', '200', 'Molly O\'Brien: Living with Makaton');
banner2.addLink('http://www.makaton.org/about/stories.htm', 'Living with Makaton', 'https://www.makaton.org/images/banner/banner-nina-allen.gif', '400', '200', 'Nina Allen: Living with Makaton');
banner2.addLink('http://www.makaton.org/about/stories.htm', 'Living with Makaton', 'https://www.makaton.org/images/banner/banner-paul-harvey.gif', '400', '200', 'Paul Harvey: Living with Makaton');
banner2.addLink('http://www.makaton.org/about/stories.htm', 'Living with Makaton', 'https://www.makaton.org/images/banner/banner-tova-kinnan.gif', '400', '200', 'Tova Kinnan: Living with Makaton');
banner2.addLink('http://www.makaton.org/about/stories.htm', 'Living with Makaton', 'https://www.makaton.org/images/banner/banner-xera-greaves.jpg', '400', '200', 'Xera Greaves: Living with Makaton');

//select a possibility at random
banner2.selectLink();


/*****************************************************************************
*****************************************************************************/



//close initialisation function
};




//image link constructor
function imageLink(linkid)
{
	//set link object
	this.link = document.getElementById(linkid);
	
	//create an empty array of possible links
	this.possibles = [];
};


//add a possibility 
imageLink.prototype.addLink = function()
{
	//store arguments in possible links array
	this.possibles[this.possibles.length] = arguments;
};


//select a possibility at random 
imageLink.prototype.selectLink = function()
{
	//if the link exists
	if(this.link != null)
	{
		//get a random item from the array
		this.rnd = this.possibles[Math.floor(Math.random() * this.possibles.length)];
		
		//set new link attributes 
		this.link.href = this.rnd[0];
		this.link.title = this.rnd[1];
		
		//get image object inside it
		this.img = this.link.getElementsByTagName('img')[0];
		
		//if it exists
		if(this.img != null)
		{
			//set new image attributes
			this.img.src = this.rnd[2]; 
			this.img.width = this.rnd[3]; 
			this.img.height = this.rnd[4]; 
			this.img.alt = this.rnd[5]; 
		}
	}
};


//call initialisation function if supported
if(typeof document.getElementById != 'undefined') { randomImageLink(); }

