 window.onload = function() {
		startCarousel();
		function startCarousel()
		{
			var img_w = 254; // carousel image width
			var img_speed = 2000; // carousel image speed
				
			jQuery.easing.easeOutQuart = function (x, t, b, c, d) { 
			    return -c * ((t=t/d-1)*t*t*t - 1) + b; 
			}; 
			var activeCarousel = 1;
			var totalCarousel = (($('#cases_container').children().size()))-1; 
			var min_x_about = totalCarousel * img_w;
			var delay = function() { next(); };
			setTimeout(delay, 7000);
					
		    function next(){
			
				// Jos caseja on vielä näyttämättä, kelataan seuraava case esiin
		    	if( activeCarousel < totalCarousel ) {
			  		var le = parseInt($("div#cases_container").css('left'));
					if (le > -min_x_about) {
						$("div#cases_container").animate({"left": "-="+img_w+"px"}, img_speed, 'easeOutQuart');
					}
			  		activeCarousel++;
			  		
			  		var delay = function() { next(); };
					setTimeout(delay,7000);
			  	}
		    	else if(activeCarousel == totalCarousel)
		    	{
		    	// Jos näytettiin vika case, kelataan taaksepäin ja tuodaan ensimmäinen case animaatiolla sisään
					$("div#cases_container").css('left', img_w);
					$("div#cases_container").animate({"left": "-="+img_w+"px"}, img_speed, 'easeOutQuart');
		    		startCarousel();
		    	}
			}
		}
	}
