 // wait until images have loaded before starting cycle

$(window).load(function() {
	// front image rotator
	$('ul#slides').cycle({ 
		fx:     'fade', 
		timeout:  2000, 
		delay:   -2000,
        before: onBefore,
		prev: '#prev',
	    next: '#next',
		pager: '.caption',
		timeout: 0
	});
});	

//hides the proceeding slides onload
$(document).ready(function() {
$("#slideshow").css("overflow", "hidden");
  $("#slides li:gt(0)").hide(); 
});

//Fix for iOS position fixed which stops the left and right frames extending to the full screen height
function changeFooterPositionLeft() {   
  $('.expandable-left').css('bottom', window.innerHeight + window.scrollY - 2000 + "px");
}

$(document).bind('scroll', function() {
  changeFooterPositionLeft();
});



//Fix for iOS position fixed which stops the left and right frames extending to the full screen height
function changeFooterPositionRight() {   
  $('.expandable-right').css('bottom', window.innerHeight + window.scrollY - 4000 + "px");
}

$(document).bind('scroll', function() {
  changeFooterPositionRight();
});




// callback fired when each slide transition begins - this centralises the images
function onBefore(curr,next,opts) {
    var $slide = $(next);
    var w = $slide.outerWidth();
    var h = $slide.outerHeight();
    $slide.css({
        marginTop: (440 - h) / 2,
        marginLeft: (540 - w) / 2
    });
};



