var container = $('#homeSlideshow');
if(slideShowImages.length > 0) {
	var imgs = [];
	for(var i = 0; i < slideShowImages.length; i++) {
		imgs[i] = '<img src="' + slideShowImages[i].path + '" alt="' + slideShowImages[i].caption + '" />';
	}
	var first = new Image();
	first.onload = function() {
		imgs.reverse();
		container.append(imgs.join(''));
		
		var $current = $('img:last', container);

		var $caption = $('<div class="caption" />')
			.html($current.attr('alt'))
			.appendTo(container);

		if(slideShowImages.length > 1) {
			setInterval(function() {
				$caption.slideToggle("fast", function() {
					$current.fadeOut("slow", function() {
						$current.prependTo(container).fadeIn(1);
						$current = $('img:last', container);
						$caption.html($current.attr('alt')).slideToggle("fast");
					});
				});
			}, 6000);
		}
	}
	first.src = slideShowImages[0].path;
}
