jQuery(document).ready(function($) {
	function loopSlides() {
		var height = '';
		$("#slideshow").fadeIn(1, function(){
			height = $('#slideshow').height();
			$('#slideshow img').each(function(n){
				var offset = (height - $(this).height())/2-35;
				$(this).css('marginTop',offset);
				$(this).delay(n*7000).show('fade',1800,function(){
					$(this).delay(4000).hide('fade',1000);
				});
			});
			var i = $('#slideshow img').length*7000;
			var t = setTimeout(loopSlides,i)
		});
	}
	$.ajax({
		method: "get",
		url: "slideshow/slideshow.html",
		dataType: "html",
		beforeSend: function(){
			$('img[src*="AS_animation.gif"]').hide();
		},
		error: function(html){
			$('img[src*="AS_animation.gif"]').parent().html(html);
		},
		success: function(html){
			$('img[src*="AS_animation.gif"]').parent().html(html);
		},
		complete: function(){
			loopSlides();
		}
	});
});
