var index = 0;
var images = [];
var current = null;
function transition() {
	index++;
	if (index >= images.length) {
		index = 0;
	}
	current.fadeOut(function() {
		$('#featured').prepend(images[index].hide());
		current.remove();
		images[index].fadeIn()
		current = images[index];
	});
};
function initHomepageFeatured() {
	current = $('#featured li:first');
	images.push(current);
	$('#featured li:not(:first)').each(function() {
		images.push($(this));
		$(this).remove();
	});
	window.setInterval(transition, 7500);
}

$(function() {
	if ($('body').is('#homepage')) {
		initHomepageFeatured();
	}
	if ($('#gallery').length) {
		$('#gallery a').facebox({
			loadingImage : 'scripts/facebox/loading.gif',
			closeImage   : 'scripts/facebox/closelabel.gif'
		});
	}
});
