$(document).ready(
function()
{
	//hide Noscript show Script
	if ($('.nos').length > 0)
		$('.nos').hide();
	if ($('.scr').length > 0)
		$('.scr').show();
	
	$('#scrollImages').children('.viewer').each(
	function()
	{
		$(this).imageScroller({
			next:$(this).children().attr('id') + '_next',
			prev:$(this).children().attr('id') + '_prev',
			frame:$(this).children().attr('id'),
			width:100,
			child:'img',
			auto:false
		});
	});
	
	//Load slideshow. Added via javascript to reduce page load time during first page load.
	$('#banner').prepend($(new Image()).load(function() {
		$('#banner').prepend($(new Image()).load(function() {
			$('#banner').prepend($(new Image()).load(function() {
				$('#banner').prepend($(new Image()).load(function() {
					titleLoop(true);
				}).attr('src','img/_design/banner_3.jpg').attr('alt','The Straight'));
			}).attr('src','img/_design/banner_4.jpg').attr('alt','The Straight'));
		}).attr('src','img/_design/banner_0.jpg').attr('alt','Caversham Bridge'));
	}).attr('src','img/_design/banner_5.jpg').attr('alt','The Boat Club'));
	
	if(typeof click == 'function')
		click();
});

var key = 0;
var last;
var count;

function titleLoop(first)
{
	if(key >= $('#banner').children('img').size())
		key = 0;
	
	if (first)
		key = $('#banner').children('img').size() - 1;
		
	for(i = 0; i < $('#banner').children('img').size(); i++)
	{
		if(key == i)
			var newEle = $('#banner').children('img')[i];
		if(last == i)
			var oldEle = $('#banner').children('img')[i];
	}
	if(newEle)
		$(newEle).fadeIn(1100);
	if(oldEle)
		$(oldEle).fadeOut(1100);
	
	last = key;
	key = key + 1;
	setTimeout ('titleLoop()', 5000 );
}
