$(function() {
	$('.dosanite_slideshow .section:first-child .caption').show();
	$('.dosanite_slideshow').each(function(index, domElm){
		setInterval( "slideSwitch("+index+")", 20000);
	});
});

function slideSwitch(inputIndex) {
	var baseBlock;
	$('.dosanite_slideshow').each(function(index, domElm){
		if(inputIndex == index){
			baseBlock = domElm;
			return false;
		}
	});
	
	if ($(baseBlock).find('.section').length < 2){
		// single item will not proceed.
		return false;
	}
	var $active = $(baseBlock).find('.active');
	if ( $active.length == 0 ){
		$active = $(baseBlock).find('.section:last');
	}
	var $next = $active.next().length ? $active.next() : $(baseBlock).find('.section:first');
	$active.addClass('last-active');
	$active.children(".caption").hide();
	$next.css({opacity: 0.0})
		.addClass('active')
		.animate({opacity: 1.0}, 1000, function() {
			$active.removeClass('active last-active');
			$next.children(".caption").show();
		});
}