// console.log('***theme/js/scripts.js loaded!***');
//$("#story").hide();


$(document).ready(function() {
		
		$("#continue-reading").click(function(){
			
			$(this).text($(this).text() == 'continue reading' ? 'close this' : 'continue reading');
			$("#story").slideToggle("slow", function(){
				return false;
			});

		});
		
		
		$('.slideshow').cycle({
		    		fx: 'fade' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
		});
		
		$('.slideCaption').hide().animate({opacity: 0.0}, 1);
		$('#promoSlide').css('background','#000 url("/global/theme/images/loader.gif") no-repeat 50% 50%');

	    $('#promoSlide').cycle({
		    timeout: 9000, 
			fx: 'fade',
			speed: 1000,
			pause:   1,
			before:  onBefore,
			after:  onAfter
		});

		function onBefore() {
			var imageN = this.id.split('_').slice(-1);
		    var imageBefore = imageN-1;
			var totImages = $(this).siblings().length + 1;
			$('#promoSlide').css('background-image','none');
		
			if (imageBefore==0) {imageBefore = totImages};
		
			$('#am'+imageN).addClass('alt2').removeClass('alt1');
			$('#am'+imageBefore).addClass('alt1').removeClass('alt2');
		}
		
		function onAfter() {
			$(this).find('.slideCaption').show().animate({opacity: 0.7}, 500).animate({bottom: "0px"}, { queue:false, duration: 500 }).animate({opacity: 0.7}, 6000).animate({opacity: 0.0, bottom: "-40px"}, 500);
		}


});
