// initialize after DOM load
$(document).ready(function(){

	linkTargets();

	var $bannerCheck = $('#banner li.active');

	if ( $bannerCheck.siblings().length > 0) {

		setInterval("fadeSwitch()", 5000);

	}

});



// LINKS
function linkTargets() {
	$('a.offsite').click(function() { window.open(this.href); return false; });
	$('a.newwin').click(function() { window.open(this.href); return false; });
};



// FADE
function fadeSwitch() {

	var $active = $('#banner li.active');

	var $next = $active.next().length ? $active.next() : $('#banner li:first');

	$active.addClass('last-active');
	$active.removeClass('active');

	$next.css({opacity: 0.0})
		.addClass('active')
		.animate({opacity: 1.0}, 800, function() {
			$active.removeClass('last-active');
		});

};
