//General variables
var rotDelay = 20000; //Milliseconds to delay before rotating
var counterHead = 0; //Current header image
var counterFoot = 1; //Current footer image

//Holds the images to rotate in the banner
var banImages = new Array();
banImages[0]=['/images/lpic1_ad.png']; //image 1
banImages[1]=['/images/services_ad.png']; //image 2

//Holds the links to rotate along with the banner images
var banLinks = new Array();
banLinks[0]=['/training.html']; //link 1
banLinks[1]=['/services.html']; //link 2

//Changes to the next image and link
function rotateHeadImage() {
	var oldImage = $('#headBannerImg').attr('src');

	$('#headBanner').css({backgroundImage: "url('" + oldImage + "')"});

	$('#headBannerImg').attr('src', banImages[counterHead]).hide().fadeIn('slow'); //Set the image
	$('#headBannerLink').attr('href', banLinks[counterHead]); //Set the link

	counterHead++;

	//Make sure the counter doesn't need to be rolled over
	if(counterHead >= banImages.length) {
		counterHead = 0;
	}
}

//Changes to the next image and link
function rotateFootImage() {
	var oldImage = $('#footBannerImg').attr('src');

	$('#footBanner').css({backgroundImage: "url('" + oldImage + "')"});

	$('#footBannerImg').attr('src', banImages[counterFoot]).hide().fadeIn('slow'); //Set the image
	$('#footBannerLink').attr('href', banLinks[counterFoot]); //Set the link

	counterFoot++;

	//Make sure the counter doesn't need to be rolled over
	if(counterFoot >= banImages.length) {
		counterFoot = 0;
	}
}

//Initialization function
$(function(){
	//Set up the initial values for the image and the link
	$('#headBannerImg').attr('src', banImages[counterHead]); //Set the image
	$('#headBannerLink').attr('href', banLinks[counterHead]); //Set the link
	$('#footBannerImg').attr('src', banImages[counterFoot]); //Set the image
	$('#footBannerLink').attr('href', banLinks[counterFoot]); //Set the link	

	//Set the images up to rotate
	setInterval(rotateHeadImage, rotDelay);
	setInterval(rotateFootImage, rotDelay);	
});

