﻿var stopDelay = false;

function justPublishedRotation() {    
	$('.fpsectiontop').css('min-height', '275px');

	// Hide all the "Just Published" book sections
	$('.justPublishedRotation').hide();

	// Show the last hidden "Just Published" book section after 7-seconds
	$('.justPublishedRotation:hidden:last')
	.fadeIn('fast')
	.delay(7000)
	.fadeOut('fast', function () {
	    var $thisElement = $(this);

	    if (!stopDelay) {
	        $thisElement.prependTo($thisElement.parent());
	        justPublishedRotation();
	    }
	});
}

function slideSwitch() {
    var $active = $('#slideshow .active');
    if ($active.length == 0) $active = $('#slideshow img:last');
    var $next = $active.next().length ? $active.next()
	            : $('#slideshow img:first');

    $active.addClass('last-active');

    $next.css({ opacity: 0.0 })
		            .addClass('active')
    //adjust value to change the time taken to fade between images
		            .animate({ opacity: 1.0 }, 0, function () {
		                $active.removeClass('active last-active');
		            });
}

$(document).ready(function () {
    justPublishedRotation();
    setInterval("slideSwitch()", 7000);
});



