fnSlideshow = function(){

	//options
	slideShowPause=6000;

	//ensure the slides are hidden
	$("#whatson .item").hide();
			
	//show the first slide, add on state
	$("#whatson .item:eq(0)").addClass("on").show();
			
	//set time interval
	runSlideshow = setInterval( "fnSlideSwitch()", slideShowPause );
	
	$("#whatson").mouseover( function(){
		clearInterval(runSlideshow);
	}).mouseout( function(){
		runSlideshow = setInterval( "fnSlideSwitch()", slideShowPause );
	});

};
fnSlideSwitch = function(){
	// hide current and show next
	$("#whatson .item.on").removeClass("on").fadeOut(1500).next(".item").addClass("on").fadeIn(1500);
	//check if that was the last item
	if ($("#whatson .item.on").length==0){
		$("#whatson .item:eq(0)").addClass("on").fadeIn(1500);
	};
};
$(document).ready(function(){

	// add class to body to show we have javascript
	$("body").addClass("js");

	// homepage events box
	$('#eventHighlights ul li').append('<p class="more">More</p>').append('<p class="less">Less</p>').find('.less').hide();
	$('#eventHighlights ul li').find('.details').hide();
	$('#eventHighlights ul li .more').click(function() {

		currentLI = $(this).parent();

		$(currentLI).find('.more').hide();
		$(currentLI).find('.less').show();
		$(currentLI).addClass('on').find('.details').slideDown('slow');
		$(currentLI).parent().find('li:not(.on)').slideUp('slow');

		$('#eventHighlights ul li .less').click(function() {

			theUL = $(this).parent().parent();
		
			$(theUL).find('.more').show();
			$(theUL).find('.less').hide();
			$(theUL).find('li').removeClass('on').slideDown('slow');
			$(theUL).find('.details').slideUp('slow');

		});

	});

	// run events slideshow, there is more than one
	noOfSlideshows = $('#whatson div.item').size();
	if(noOfSlideshows != 1) {
		fnSlideshow();
	};

});