
	jQuery(window).load(function() {
		var $ = jQuery,
			slideDuration = 8000,
			fadeDuration = 2000;
		
		
		$("ul.image-animation").each(function() {
			
			var viewport = {
				width: $(this).width(),
				height: $(this).height()
			}
			
			var images = $("li", this),
				currentIndex = images.length-1;
				
			function fadeImage(currentImage) {
				
				var startAt = currentIndex % 2 ? 0 : -100,
					stopAt = currentIndex % 2 ? -100 : 0;
				
				
				
				
				currentImage.show().css("top", startAt).animate({top:stopAt}, {queue:false, duration: slideDuration, easing: "linear"});
				window.setTimeout(function() {
					currentIndex = currentIndex > 0 ? currentIndex-1 : images.length-1;
					var nextImage = $(images.get(currentIndex));
					
					if (currentIndex == images.length-1) {
						nextImage.fadeIn(fadeDuration);
					}
					else {
						currentImage.fadeOut(fadeDuration);
					}
					
					fadeImage(nextImage);
				}, slideDuration-fadeDuration);
			}
			fadeImage($(images.get(currentIndex)));
			
		});
		
	});
