function rotateImage() {
	$('img.sponsor-active').animate({'opacity': 0}, 199, function () {
		$(this).css('display', 'none');
		$(this).removeClass('sponsor-active');
		var next = $(this).next();
		if (next.length == 0) {
			next = $(this).siblings(':first');
		}
		next.css({
		  'opacity': '0',
		  'display': 'inline'
		});
		next.animate({'opacity': 1}, 307);
		next.addClass('sponsor-active');
	});
}

function fadeImage() {
	var active = $('img.front-active'),
	next = active.next();
	if (next.length == 0) {
		next = active.siblings(':first');
	}
	next.css({
		'opacity': 0,
		'display': 'block'
	});
	active.animate({'opacity': 0}, 401);
	
	next.animate({'opacity': 1}, 401, function() {
		active.removeClass('front-active');
		next.addClass('front-active');
	});
}

function sponsorTimer () {
	rotateImage();
	var t = setTimeout("sponsorTimer()", 5003);
}

function frontTimer () {
	fadeImage();
	var t = setTimeout("frontTimer()", 7001);
}

$(document).ready(function () {
	if ($('img.sponsor-active').length !== 0) {
		var t = setTimeout("sponsorTimer()", 5003);
	}
	
	if ($('img.front-image').length > 1) {
		var t = setTimeout("frontTimer()", 7001);
	}
	
});
