/*
Background and normal image rotators require:

imagePath - '/images/background/image_' would create a list a images called '/images/background/image_0.jpg' etc
maxNumber - the maxNumber will be used as the limit to what is added onto the imagePath
extention - the extention of the files

ShowRandBgImg requires 'bgColour' - a color as specified in CSS e.g. 'transparent' or '#FF0000' and 'imageRepeat' - use CSS to specify i.e. 'no-repeat' - 'repeat-x' - 'repeat-y'
ShowRandImg requires altText - i.e. a description of the images in general

Calls to ShowRandImg require only the struct you wish to use as the image source.

Calls ot ShowRandBgImg require the elementId, imagePosition as specified in CSS (e.g. 'top right') and the struct defenition you wish to use

*/

/* WHEN CREATING A STRUCT USE THE PREFIX "bg" or "img" TO SPECIFY WHICH FUNCTION IT SHOULD BE USED FOR */

/* Struct defenitions -----------------------------------------------*/
var bgExample = {
	imagePath: 'http://fettes.test.webadvertising.co.uk/images/background_rotator/behind_image_',
	maxNumber: 9,
	extention: 'jpg',
	bgColour: '#FFFFFF',
	imageRepeat: 'no-repeat'
}

var imgExample = {
	imagePath: '/Prospective/Prep/images/rotator/fettesprep_',
	maxNumber: 44,
	extention: 'jpg',
	altText: 'Fettes College Edinburgh'
}

var imgHeader = {
	imagePath: '/Images/Rotator/header_',
	maxNumber: 8,
	extention: 'jpg',
	altText: 'Windsor Urology',
	width: '840px',
	height: '225px'
}

/* Function defenitions --------------------------------------------- */
function ShowRandImg(imageData)
{
	var now=new Date();
	var status=(now.getSeconds())%imageData.maxNumber;

	document.write('<img src="'+imageData.imagePath+status+'.jpg" alt="' + imageData.altText + '" width="' + imageData.width + '" height="' + imageData.height + '" />');
}

function ShowRandBgImg(elementId, imagePosition, imageData)
{
	var now=new Date();
	var randNumber=(now.getSeconds())%imageData.maxNumber;
	var div = document.getElementById(elementId);
	if(div != null)
	{
		div.style.background = imageData.bgColour + ' url('+ (imageData.imagePath + randNumber) + '.' + imageData.extention + ') ' + imagePosition + ' ' + imageData.imageRepeat;
	}
	else
	{
		alert('The elementId ' + elementId + 'could not be found.');
	}
}