
//open initialisation function
function randomImageLink() { 
//************************************************



/*****************************************************************************
 Define image links
*****************************************************************************/


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

//add possibilities ('href', 'title text', 'src', 'width', 'height', 'alt text')
button.addLink('http://www.securit.com/', 'Securit', 'ads/securit.gif', '449', '65', 'Securit');
button.addLink('http://www.munters.us/en/us/Division-start-pages/HumiCool/', 'Munters', 'ads/munters.gif', '449', '65', 'Munters');
//button.addLink('http://www.livingstonintl.com/View.aspx?locale=en-ca&uid=ManagedServices', 'Livingston', 'ads/livingston.gif', '449', '65', 'Livingston');
button.addLink('http://www.filebank.ca/', 'File Bank', 'ads/filebank.gif', '449', '65', 'File Bank');
button.addLink('http://www.firstonsite.ca/', 'First on Site', 'ads/firstonsite.gif', '449', '65', 'First on Site');
button.addLink('http://www.secural.com/', 'Secural DataShred', 'ads/secural.gif', '449', '65', 'Secural DataShred');
//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
//alert('typeof(this.img): '+typeof(this.img));
		if(this.img != null && typeof(this.img)=='object')
		{
			//set new image attributes
			if(typeof(this.rnd[2])=='undefined' || typeof(this.rnd[2])!='string'){return false;}
			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(); }

