
	$(document).ready(function() {
    	$('.slideshow').cycle({
	fx: 'fade', //choose your transition type, ex: fade, scrollUp, shuffle, etc...
	fit: 1,
	//timeout: 4000,
	delay: 1000
	});
	});
	
		$(document).ready(function() {
    	$('.slideshow2').cycle({
	fx: 'fade', //choose your transition type, ex: fade, scrollUp, shuffle, etc...
	fit: 1,
	//timeout: 4000,
	delay: 3000
	});
	});
		
		$(document).ready(function() {
    	$('.slideshow3').cycle({
	fx: 'fade', //choose your transition type, ex: fade, scrollUp, shuffle, etc...
	fit: 1,
	//timeout: 4000,
	delay: 6000
	});
	});
		
		$(document).ready(function() {
    	$('.slideshow4').cycle({
	fx: 'fade', //choose your transition type, ex: fade, scrollUp, shuffle, etc...
	fit: 1,
	//timeout: 4000,
	delay: 11000
	});
	});

//Cycle plugin for Adrian Campbell-Howard pages

jQuery.easing.def = "easeInOutQuart"; // apply easeInOutQuart easing
$(document).bind('keypress', function(e) {
     if (e.keyCode == 37)
         $('#slideshow').cycle('prev');
      else if (e.keyCode == 39,19)
         $('#slideshow').cycle('next');
		 });
var opts, startingSlide = 0;
function starttouchCycle() {
    opts = $('#slideshow')
	.cycle({
		fx:     'scrollHorz',
		speed:  1700,
		cssBefore: { opacity: 0 },
		timeout: 5000,
   		animOut: { opacity: 0 },
   		animIn: { opacity: 1 },
		next:   '.next, .image, #slidePrev, #slideNext',
		prev:   '.prev, #slidePrev',
		pager:  '#nav',
		after:   onAfter,
		startingSlide: startingSlide,
    }).data('cycle.opts');
	//
	$('.noclick').unbind("click");
}

function startCycle() {
    opts = $('#slideshow')
	.cycle({
		fx:     'scrollHorz',
		speed:  1700,
		cssBefore: { opacity: 0 },
		timeout: 5000,
   		animOut: { opacity: 0 },
   		animIn: { opacity: 1 },
		next:   '.next, .image, #slidePrev, #slideNext',
		prev:   '.prev, #slidePrev',
		pager:  '#nav',
		after:   onAfter,
		startingSlide: startingSlide,
    }).data('cycle.opts');
	//
	$('.noclick').unbind("click");
}

function onAfter(curr,next,opts) {
	var counter = (opts.currSlide + 1) + ' / ' + opts.slideCount;
	$('#counter').html(counter);
	//
	var caption = $(next).children('img').first().attr("title");
	$('#caption').html(caption);
}


$(document).ready(function() {
		
	//for pc's
	if ($('html').hasClass('no-touch')) {
	
		startCycle();
		
		$(window).resize(function(){
			startingSlide = opts.currSlide;
			$('#slideshow').cycle('destroy');
			startCycle();
		});
	}

	//for touchscreens
	if ($('html').hasClass('touch')) {
	
		$(function() {
		 $('#slideshow').swipe({
		  swipeLeft: function() { $('#slideshow').cycle("next"); },
		  swipeRight: function() { $('#slideshow').cycle("prev") },
		  threshold: {
		   x: 15,
		   y: 99999
		  },
		  preventDefaultEvents: false
		 });
		});
	
		starttouchCycle();
		
		$(window).resize(function(){
			startingSlide = opts.currSlide;
			$('#slideshow').cycle('destroy');
			starttouchCycle();
		});
	}
});

		window.onorientationchange = function() {
			$('#slideshow, #bio_part img').cycle('destroy');
		}

		$(window).resize(function(){
			startingSlide = opts.currSlide;
			$('#slideshow').cycle('destroy');
			starttouchCycle();
		});
