// 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
*****************************************************************************/


//identify an image link ('link-id')
var button = new imageLink('udm-button');

//add possibilities ('href', 'title text', 'src', 'width', 'height', 'alt text')
button.addLink('http://collective.crystalled-roses.net', ' ', 'http://www.crystalled-roses.net/collective/buttons/link100x50_02.jpg', '100', '50', 'White Allurement - Fanlisting Collective');
button.addLink('http://listing.crystalled-roses.net/akshay', ' ', 'http://www.crystalled-roses.net/listing/akshay/codes/100x50_05.jpg', '100', '50', 'King Khiladi - Akshay Kumar Fanlisting');
button.addLink('http://listing.crystalled-roses.net/arjun', ' ', 'http://www.crystalled-roses.net/listing/arjun/codes/100x50_04.jpg', '100', '50', 'Rampalicious - Arjun Rampal Fanlisting');
button.addLink('http://listing.crystalled-roses.net/arashri', ' ', 'http://www.crystalled-roses.net/listing/arashri/codes/100x50_04.jpg', '100', '50', 'Perfectly Matched - Arjun Rampal/Aishwarya Rai/Hrithik Roshan Fanlisting');
button.addLink('http://listing.crystalled-roses.net/kareena', ' ', 'http://www.crystalled-roses.net/listing/kareena/codes/100x50_04.jpg', '100', '50', 'An Overated Desperado - Kareena Kapoor Hatelisting');
button.addLink('http://listing.crystalled-roses.net/lberghol', ' ', 'http://www.crystalled-roses.net/listing/lberghol/codes/100x50_02.gif', '100', '50', 'Fantastique - Lauren HP Fanarts Fanlisting');
button.addLink('http://listing.crystalled-roses.net/lillywmw', ' ', 'http://www.crystalled-roses.net/listing/lillywmw/codes/100x50_04.jpg', '100', '50', 'Undefined - Lilly HP Fanarts Fanlisting');
button.addLink('http://listing.crystalled-roses.net/ranbir', ' ', 'http://www.crystalled-roses.net/listing/ranbir/codes/100x50_02.jpg', '100', '50', 'The Descendent - Ranbir Kapoor Fanlisting');
button.addLink('http://listing.crystalled-roses.net/roncormac', ' ', 'http://www.crystalled-roses.net/listing/roncormac/codes/100x50_01.jpg', '100', '50', 'Ron vs. Cormac - rivalry fanlisting');
button.addLink('http://listing.crystalled-roses.net/rhrfanarts', ' ', 'http://www.crystalled-roses.net/listing/rhrfanarts/codes/100x50_02.gif', '100', '50', 'Amorous Sentiments - Ron/Hermione Fanarts Fanlisting');
button.addLink('http://listing.crystalled-roses.net/ronlavender', ' ', 'http://www.crystalled-roses.net/listing/ronlavender/codes/100x50_03.jpg', '100', '50', 'Spiteful Fling - Ron/Lavender Hatelisting');
button.addLink('http://listing.crystalled-roses.net/refanfic', ' ', 'http://www.crystalled-roses.net/listing/refanfic/codes/100x50_03.jpg', '100', '50', 'One Step Closer - Rupert/Emma Fanfictions Fanlisting');
button.addLink('http://listing.crystalled-roses.net/siriusmione', ' ', 'http://www.crystalled-roses.net/listing/siriusmione/fanlisting/codes/100x50_04.jpg', '100', '50', 'Siriusly Mione - Sirius/Hermione Fanlisting');
button.addLink('http://listing.crystalled-roses.net/sadendings', ' ', 'http://listing.crystalled-roses.net/sadendings/codes/100x50_04.jpg', '100', '50', 'Bereaved Denouement - Sad Endings Fanlisting');

//select a possibility at random
button.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(); }
