//file settings
function imageSwap(base)
{
		var filePath = base+"images/icet/headerImages/photo"; //begin dir + fileName
		var photoNum = 9; //number of photo's to loop through
		var fileEnd = ".jpg"; // extention
		
		//html-jquery settings
		var frontDiv = "#headerImage"; 
		var backDiv = "#headerBackImage";
		
		//time settings
		var speed = 1000;// 1000 == 1 second
		var imgVisible = 10; // loop counts (minimum 4)
		var fadeOut = 2; // loops needed to fadeOut(maximumValue = imgVisible -3)
		
		// Generates a photo slide with the above settings.
		// Don't change this code !
		$(document).everyTime(speed, function(i) {
			// time == the i value that resets after (photoNum * imgVisible)
			// so if (photoNum * imgVisible) = 50 and i = currently 55
			// then time = 5
			// when i == 50  or any rounded multiplycation of 50 time = 0;
			var time = i % (photoNum * imgVisible); 
			// same as above fade == i that resets after imgVisible
			var fade = i % imgVisible;
			// get the current foto parsed to int to round the outcome
			var current = parseInt((time  / imgVisible) + 1);
			// checks when the loop ends and sets the next photo to the first when true
			if((i + imgVisible) % (photoNum * imgVisible) <= imgVisible)
				var next = 1;
			else
				var next = current+1;
			// path of the first img
			var img = filePath + current + fileEnd;
			// path of the second img
			var img2 = filePath + next + fileEnd;
			
			// when fade is set back to zero make front visible
			if( fade == 0)
			{
				$(frontDiv).css("display","block");
			}
			// when cycled ones through the loop set the back image
			if(fade == 1)
			{
				$(backDiv).css("backgroundImage","url(" + img2 + ")");
			}
			// when the loop 
			if(fade == (imgVisible - fadeOut - 1))
			{
				$(frontDiv).fadeOut(fadeOut * speed);
			}
			if(fade == imgVisible - 1)
			{
				$(frontDiv).css("backgroundImage","url(" + img2 + ")");
			}
		});
}
