
	/**
	*	By Chris Duxbury
	*	Requires jQuery.
	**/
	var curBanner = 0;
	var stopped = false;

	$(document).ready( function() {
		$('#rotator a').children().not('img:first').hide();
		$('#rotator a img').each(function(index){
			var caption = document.createElement('div');
			var innerCaption = document.createElement('div');
			var rotatorInner = document.createElement('div');
			$(rotatorInner).addClass('rotatorInner');
			$(caption).addClass('caption');
			$(caption).css('top', (index * 80) + (7 * index) + 10);
			$(caption).click(function(){window.location = $('#rotator a').eq(index).attr('href')});
			$(innerCaption).addClass('innerCaption');
			$(innerCaption).append('<h3>' + $(this).attr('title') + '</h3>');
			$(innerCaption).append($(this).parent().nextAll('p:first'));
			$(innerCaption).append('<span class="byLine">' + $(this).attr('alt') + '</span>');
			$(caption).hover(
				function() {
					curBanner = index;  					
					showBanner(index);
					stopped = true;
				},
				function(){
					stopped = false;
				}
			);
			$(caption).append(innerCaption);
			$('#rotator').append(caption);
		});
		$('#rotator .caption p').show();
		$('#rotator .caption:first').attr('id','current');
		slideShow();
	});
	function slideShow() {
		showBanner(curBanner);
		if(curBanner >= $('#rotator a img').length - 1) {
			curBanner = 0;	
		} else {
			curBanner++;
		}			
		$('#rotator a img').eq(curBanner).clearQueue().delay('3000').hide(0,slideShow);
	}
	/**
	*	Recusrively called to show the image at the specified index and highlight the associated caption.
	*/
	function showBanner(index) {
		$('#rotator .caption').attr('id','');
		$('#rotator .caption').eq(index).attr('id','current');
		$('#rotator a img').hide();
		$('#rotator a img').eq(index).show();
	}

