$(document).ready(function() {
	if ($('div.imageCycleContainer').length > 0) {
		cycleImagesInit();
		setInterval('cycleImages()', 7000);
	}
});

function cycleImagesInit() {
	$('div.imageCycleContainer').each(function() {
		var active = $(this).find('.active');
		if (active.length == 0) $(this).find('img:first').addClass('active');
	});
}

function cycleImages() {
	$('div.imageCycleContainer').each(function() {
		if ($(this).find('img').length > 1) {
			var active = $(this).find('.active');
			var next = ($(this).find('.active').next().length > 0) ? $(this).find('.active').next() : $(this).find('img:first');
			next.css('z-index', 2);
			active.fadeOut(1500, function() {
				active.css('z-index', 1).show().removeClass('active');
				next.css('z-index', 3).addClass('active');
			});
		}
	});
}

