			var currentimage;
			var numimages;
			var startimage;
			var play;
			var fileNamePrefix;
			var fileNameSuffix;
			var slideShowTime;
			var shuffle;
			var timeOut;

			// Settings
			shuffle = 0;
			play = 1;
			startimage = 1;
			stopimage = 7;
			
			currentimage = stopimage;
			fileNamePrefix = "./images/slideshow/";
			fileNameSuffix = ".jpg";
			slideShowTime = 5000;

			function fadeIn (image)
			{
				// Notera att Internet Explorer inte stöder egenskapen opacity, utan använder alpha(opacity) istället.
				if (document.getElementById("image_fadein").style.opacity == 0)
				// init
				{
					fadeIn.opacityValue = 0;
					document.getElementById("image_fadein").src = image;
					document.getElementById("image_fadein").style.visibility = "visible";
					document.getElementById("image_fadein").style.opacity = 0.01;	// MSIE-fix
					document.getElementById("image_fadein").style.filter = "alpha(opacity=0)";
					setTimeout ("fadeIn('" + image + "')",0);
				}
				else if (document.getElementById("image_fadein").style.opacity >= 1) // Obs! Det måste vara >=1 och inte ==1 på grund av konstiga MSIE avrundningar
				// end
				{
					fadeIn.opacityValue = 0;
					document.getElementById("slideShowPhoto").src = image;
					document.getElementById("image_fadein").style.opacity = 0;
					document.getElementById("image_fadein").style.filter = "alpha(opacity=0)";
					
					if (shuffle != 1) document.getElementById("image_fadein").src = fileNamePrefix + image + fileNameSuffix;	// Laddar in bilden innan den visas för att undvika hack pga inladdning i fadningarna

					document.getElementById("image_fadein").style.visibility = "hidden";
				}
				else
				// progressing
				{
					fadeIn.opacityValue = fadeIn.opacityValue + 0.04 || 1;
					document.getElementById("image_fadein").style.opacity = fadeIn.opacityValue;
					document.getElementById("image_fadein").style.filter = "alpha(opacity=" + ((fadeIn.opacityValue * 100)) + ")";	// MSIE-fix
					setTimeout ("fadeIn('" + image + "')",40);
				}
			}
			function show_image (image)
			{
				currentimage = image;
				if (play != 1) document.getElementById("slideShowPhoto").src = fileNamePrefix + image + fileNameSuffix;
				if (play == 1) fadeIn(fileNamePrefix + image + fileNameSuffix);
			}
			function get_next_image(oldimg)
			{
				var image = 0;
				image = oldimg + 1;
				if (image > stopimage)
				{
					image = startimage;
				}
				return image;
			}
			function get_prev_image(oldimg)
			{
				var image = oldimg;
				image=image-1;
				if (image < startimage)
				{
					image = stopimage;
				}
					
				return image;
			}
			function change_image ()
			{
	
				if (play == 1)
				{
					timeOut = setTimeout ("change_image ()",slideShowTime);	
					if (shuffle != 1) show_image (get_prev_image(currentimage));
					//if (shuffle != 1) show_image (get_next_image(currentimage));
					if (shuffle == 1) random_image();
				}
			}
			function back()
			{
				pause();
				currentimage = get_prev_image(currentimage);
				show_image(currentimage);
			}
			function forward()
			{
				pause();
				currentimage = get_next_image(currentimage);
				show_image(currentimage);
			}
			function playpause()
			{
				if (play==1)
					pause();
				else unpause();
			}
			function pause()
			{
				play=0;
				clearTimeout (timeOut);	
			}
			function unpause()
			{
				play=1;
				currentimage = get_prev_image(currentimage);
				change_image ();
			}
			function random (minNumber, maxNumber)
			{
				return Math.floor(Math.random() * (maxNumber-(minNumber)+1))+minNumber;
			}
			function random_image()
			{
				currentimage = random(startimage,stopimage);
				show_image(currentimage);
			}
			function init_playback ()
			{
				if (play == 1)
				{
					if (shuffle != 1) document.getElementById("slideShowPhoto").src = fileNamePrefix + stopimage + fileNameSuffix;
					if (shuffle == 1) document.getElementById("slideShowPhoto").src = fileNamePrefix + random(startimage,stopimage) + fileNameSuffix;
				}
				timeOut = setTimeout ("change_image ()",slideShowTime);
					
			}
		window.onload = init_playback;

