$(function() {
	var caption = $("div.exampleCaption div");
	var $active = $('#recentExamples div.active');
	if ( $active.length == 0 ) $active = $('#recentExamples div:last');
	caption.html($('span', $active).html());
    setInterval( "slideSwitch()", 12000 );
});
function slideSwitch() {
	var caption = $("div.exampleCaption div");
	var $active = $('#recentExamples div.active');
	if ( $active.length == 0 ) $active = $('#recentExamples div:last');

	// use this to pull the divs in the order they appear in the markup
	var $next =  $active.next().length ? $active.next() : $('#recentExamples div:first');

	caption.slideUp(1000, function() {
		$active.fadeTo(2000,0);
		caption.html($('span', $next).html());
		$active.addClass('lastActive');
	
		$next.css({display: 'none'})
		.addClass('active')
		.fadeTo(2000,1, function() {
			$active.removeClass('active lastActive');
			caption.slideDown(500);	
		});
		
	});
}