// Keeps slider centered
function sizeLayer()
{
	var divSize = 1200;
	var div = $('#splash');
	var layerSize = (document.documentElement.clientWidth - divSize)/2;
	if ($(window).width() <= '1000') { div.css({left: '-100px'}); }
	else { div.css({ left: layerSize + 'px' }); }
}
$(document).ready(sizeLayer);
$(window).load(function(){
	var slideTime = 10000;
	$('#slider').cycle({
		fx: 'fade',
		timeout: slideTime,
		speed: 1000,
		before: beforeSlide,
		after: afterSlide,
		pager: '#pager',
		delay: 0,
		sync: true,
		clearType: true
	});
	function beforeSlide(){
		var info = $(this).children('.info');
		var heading = info.children('h2');
		var copy = info.children('p');
		var button = info.children('a.more');
		// Reset slide
		heading.fadeTo(0, 0);
		copy.fadeTo(0, 0);
		button.fadeTo(0, 0);
		info.css({ top: '450px', paddingBottom: '500px', height:'auto', width:'675px'});
	}
	function afterSlide() {
		var info = $(this).children('.info');
		var heading = info.children('h2');
		var copy = info.children('p');
		var button = info.children('a.more');
		// In animation
		info.animate({ top: '75px', paddingBottom: '20px'}, 1000, 'easeOutCubic', function(){
			heading.fadeTo(500, 1);
			copy.delay(500).fadeTo(500, 1);
			button.delay(1000).fadeTo(500, 1);
			// Out animation
			var outAnimation = (slideTime - 5000);
			heading.delay(outAnimation).fadeTo(250, 0);
			copy.delay(outAnimation).fadeTo(250, 0);
			button.delay(outAnimation).fadeTo(250, 0);
			info.delay(outAnimation + 2000).animate({ top: '-50px', height:'0px'}, 1000, 'easeInCubic');
		});
	}
});

$(window).bind('resize', sizeLayer);

