$(document).ready(function(){
	
	// Set some variables
	var wHeight = $(window).height();	
	var $main = $('.csstransitions [role="main"] .inner');
	var mainHeight = $main.height();

	// Set main content vertical align
	$main.css({marginTop:-mainHeight / 2});
	
	// Click to play video
	$('[role="secondary"] a').click(function() {
		$('body').addClass('video');
		$(this).fadeOut(800, function() {
			$(this).parent().find('#video-player').fadeIn(800);
			if ($('html').hasClass('csstransitions')) {
				$('footer[role="contentinfo"]').hide();
				$('video').get(0).play();
			}
		});
		return false;
	});
	
	// Click to pause/close video
	$('[role="secondary"] span').click(function() {
		$('body').removeClass('video');
		$('#video-player').fadeOut(600, function() {
			$('[role="secondary"] a').fadeIn(1200);
		});
		if ($('html').hasClass('csstransitions')) {
			$('footer[role="contentinfo"]').show();
			$('video').get(0).pause();
		}
		return false;
	});
	
	// Load Vimeo for older browsers
	$('.no-csstransitions #video-player').find('video').hide();
	$('.no-csstransitions #video-player').append('<iframe src="http://player.vimeo.com/video/6544927?title=0&amp;byline=0&amp;portrait=0&amp;color=696969" width="640" height="352" frameborder="0"></iframe>');
	
	
});
