// 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
*****************************************************************************/

// This is the button for the bottom left section.

//identify an image link ('link-id')
var button = new imageLink('stamp_img');

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

button.addLink('', '', 'http://www.thompsonspiritway.ca/wp-content/uploads/homephoto1.png', '360', '271', '');
button.addLink('', '', 'http://www.thompsonspiritway.ca/wp-content/uploads/homephoto2.png', '360', '271', '');
button.addLink('', '', 'http://www.thompsonspiritway.ca/wp-content/uploads/homephoto3.png', '360', '271', '');
button.addLink('', '', 'http://www.thompsonspiritway.ca/wp-content/uploads/homephoto4.png', '360', '271', '');
button.addLink('', '', 'http://www.thompsonspiritway.ca/wp-content/uploads/homephoto5.png', '360', '271', '');
button.addLink('', '', 'http://www.thompsonspiritway.ca/wp-content/uploads/homephoto6.png', '360', '271', '');
button.addLink('', '', 'http://www.thompsonspiritway.ca/wp-content/uploads/homephoto7.png', '360', '271', '');




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


// This is the button for the bottom right section.

//identify an image link ('link-id')
var button4 = new imageLink('br-button');

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

button4.addLink('http://69.27.112.53/wood/', '', 'http://69.27.112.53/wood/wp-content/uploads/bottom_right_excalibur.jpg', '204', '478', '');

button4.addLink('http://69.27.112.53/wood/', '', 'http://69.27.112.53/wood/wp-content/uploads/bottom_right_magswitch.jpg', '204', '478', '');



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


// This is the button for the top right section.

//identify an image link ('link-id')
var button3 = new imageLink('tr-button');

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

button3.addLink('http://69.27.112.53/wood/', '', 'http://69.27.112.53/wood/wp-content/uploads/top_right_benchdog.jpg', '206', '295', '');

button3.addLink('http://69.27.112.53/wood/', '', 'http://69.27.112.53/wood/wp-content/uploads/top_right_tormek.jpg', '206', '295', '');

button3.addLink('http://69.27.112.53/wood/', '', 'http://69.27.112.53/wood/wp-content/uploads/top_right_woodpecker.jpg', '206', '295', '');



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





// This is the button for the top banner section.

var button1 = new imageLink('tb-button');

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


// 1
button1.addLink('http://69.27.112.53/wood/', '', 'http://69.27.112.53/wood/wp-content/uploads/top_banner_benchdog.jpg', '645', '114', '');

// 2
button1.addLink('http://69.27.112.53/wood/', '', 'http://69.27.112.53/wood/wp-content/uploads/top_banner_trend.jpg', '645', '114', '');

// 3
button1.addLink('http://69.27.112.53/wood/', '', 'http://69.27.112.53/wood/wp-content/uploads/top_banner_wixey.jpg', '645', '114', '');




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



// This is the button for the pther centre section.

var button2 = new imageLink('cb-button');

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

// 1 
button2.addLink('http://69.27.112.53/wood/', '', 'http://69.27.112.53/wood/wp-content/uploads/centre_panasonic.jpg', '434', '293', '');

// 2 
button2.addLink('http://69.27.112.53/wood/', '', 'http://69.27.112.53/wood/wp-content/uploads/centre_trend.jpg', '434', '293', '');

// 3
button2.addLink('http://69.27.112.53/wood/', '', 'http://69.27.112.53/wood/wp-content/uploads/centre_woodpecker.jpg', '434', '293', '');






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


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

var button5 = new imageLink('sidebar_banner1');

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

// 1 
button5.addLink('http://69.27.112.53/wood/', '', 'http://69.27.112.53/wood/wp-content/uploads/bottom_left_Byrd.jpg', '211', '188', '');

// 2 
button5.addLink('http://69.27.112.53/wood/', '', 'http://69.27.112.53/wood/wp-content/uploads/bottom_left_DEWALT.jpg', '211', '188', '');






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


var button6 = new imageLink('sidebar_banner2');

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

// 1 
button6.addLink('http://69.27.112.53/wood/', '', 'http://69.27.112.53/wood/wp-content/uploads/bottom_left_Byrd.jpg', '211', '188', '');

// 2 
button6.addLink('http://69.27.112.53/wood/', '', 'http://69.27.112.53/wood/wp-content/uploads/bottom_left_DEWALT.jpg', '211', '188', '');







	//select a possibility at random
	button6.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(); }
