var slideshow_interval = '';
$ = jQuery.noConflict();
$(document).ready(function(){
	$('#slideshow .featured-wrap');
	setTimeout(function() {
		$('#slideshow .background:first, #slideshow .featured-wrap:first').show().addClass('current');
	}, 500);
	slideshow_interval = setInterval('cycle()', 4000);
});

function cycle() {
	var current = $('#slideshow .featured-wrap.current');
	var next_index = $(current).index('#slideshow .featured-wrap') + 1;
	var next = $('#slideshow .featured-wrap:eq('+next_index+')');
	var current_bg = $('#slideshow .background.current');
	var next_bg = $(current_bg).next('.background');
	
	if (next.length) {
		$(current).stop(true, true).fadeOut('slow').removeClass('current');
		$(next).stop(true, true).fadeIn('slow').addClass('current');
	}
	else {
		$(current).stop(true, true).fadeOut('slow').removeClass('current');
		$('#slideshow .featured-wrap:eq(0)').stop(true, true).fadeIn('slow').addClass('current');
	}
		
	if (next_bg.length) {
		$(current_bg).stop(true, true).fadeOut('slow').removeClass('current');
		$(next_bg).stop(true, true).fadeIn('slow').addClass('current');
	}
	else {
		$(current_bg).stop(true, true).fadeOut('slow').removeClass('current');
		$('#slideshow .background:eq(0)').stop(true, true).fadeIn('slow').addClass('current');
	}
}
