		function clearText(thefield){
		if (thefield.defaultValue==thefield.value)
		thefield.value = ""
		} 
				// original content taken from Nic's JavaScript Page with permission
// lack of these three lines will result in copyright infringment
// made by: Nic's JavaScript Page - http://www.javascript-page.com

function initArray() {

this.length = initArray.arguments.length;
  for (var i = 0; i < this.length; i++) {
  this[i] = initArray.arguments[i];
  }
}

link = new initArray(
"http://www.mercia-group.co.uk/budget/index.htm",
"http://www.mercia-scotland.co.uk/Scottish-Charities-Conference-2012.pdf",
"http://www.mercia-scotland.co.uk/Scotland-2012.pdf",
"http://www.mercia-group.co.uk/technical_manuals/paperless_audit.htm",
"http://www.mercia-group.co.uk/technical_manuals/specialist_assignments.htm",
"http://www.mercia-group.co.uk/marketing_support/newsletters_quarterly.htm",
"http://www.mercia-group.co.uk/training/webinars.htm",
"http://www.mercia-group.co.uk/marketing_support/budget_tax_cards.htm",
"http://www.mercia-group.co.uk/technical_support/compliance_reviews.htm",
"http://www.mercia-group.co.uk/marketing_support/totalsolution.htm"
);

image = new initArray(
"http://www.mercia-group.co.uk/images/the-complete-Budget-Service-2012-Button.jpg",
"http://www.mercia-scotland.co.uk/images/Scottish-Charities-Conference-2012-button.jpg",
"http://www.mercia-scotland.co.uk/images/scotland-programme-2012.jpg",
"http://www.mercia-group.co.uk/images/index-paperless.gif",
"http://www.mercia-group.co.uk/images/index-specialist.gif",
"http://www.mercia-scotland.co.uk/images/Newsletters_Winter_2011_button.jpg",
"http://www.mercia-scotland.co.uk/images/webinars-button.jpg",
"http://www.mercia-scotland.co.uk/images/taxcard-button.jpg",
"http://www.mercia-scotland.co.uk/images/external-audit-review-button.jpg",
"http://www.mercia-scotland.co.uk/images/websites-button.jpg"
);

text = new initArray(
"The complete budget service",
"Book now for our Scottish Charities Conference",
"2012 Training Programme",
"Are you ready to adopt Paperless Audit?",
"Are you managing the risk of Specialist Assignments?",
"Client Newsletters",
"One hour webinars",
"Personalised tax cards",
"Audit quality review",
"Website for your firm?"
);


var interval = 5; // delay between rotating images (in seconds)
interval *= 1000;
var i_max = 0;
var i_current = 0;

function rotateImage() {
//	var currentdate = new Date();
//	var core = currentdate.getSeconds() % image.length;
	i_max = image.length;
	if(i_current >= i_max)
	{		
		i_current = 0;		
	}
	core = i_current;
	var ranlink  = link[core];
	var ranimage = image[core];
	var rantext  = text[core];
	document.getElementById('ranImg').alt = rantext;
	document.getElementById('ranImgLink').href = ranlink;
	blendimage('ranImgDiv','ranImg', ranimage,500);
	i_current++;
	setTimeout("rotateImage()", interval);
}

function opacity(id, opacStart, opacEnd, millisec) {
	//speed for each frame
	var speed = Math.round(millisec / 100);
	var timer = 0;

	//determine the direction for the blending, if start and end are the same nothing happens
	if(opacStart > opacEnd) {
		for(i = opacStart; i >= opacEnd; i--) {
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	} else if(opacStart < opacEnd) {
		for(i = opacStart; i <= opacEnd; i++)
			{
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	}
}

//change the opacity for different browsers
function changeOpac(opacity, id) {
	var object = document.getElementById(id).style; 
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
}

function shiftOpacity(id, millisec) {
	//if an element is invisible, make it visible, else make it ivisible
	if(document.getElementById(id).style.opacity == 0) {
		opacity(id, 0, 100, millisec);
	} else {
		opacity(id, 100, 0, millisec);
	}
}

function blendimage(divid, imageid, imagefile, millisec) {
	var speed = Math.round(millisec / 100);
	var timer = 0;
	
	//set the current image as background
	document.getElementById(divid).style.backgroundImage = "url(" + document.getElementById(imageid).src + ")";
	
	//make image transparent
	changeOpac(0, imageid);
	
	//make new image
	document.getElementById(imageid).src = imagefile;

	//fade in image
	for(i = 0; i <= 100; i++) {
		setTimeout("changeOpac(" + i + ",'" + imageid + "')",(timer * speed));
		timer++;
	}
}

function currentOpac(id, opacEnd, millisec) {
	//standard opacity is 100
	var currentOpac = 100;
	
	//if the element has an opacity set, get it
	if(document.getElementById(id).style.opacity < 100) {
		currentOpac = document.getElementById(id).style.opacity * 100;
	}

	//call for the function that changes the opacity
	opacity(id, currentOpac, opacEnd, millisec)
}
