$(document).ready(
	function() {
		if ($('.page-home').size() > 0) {
			if ($('.panel:eq(0)').height() >= ($('.feature li:eq(0)').height() + 30)) {
				var offset = $('#download').height()*0.5;
			} else {
				var offset = $('.branding:eq(0)').height() - $('.panel:eq(0)').height() + $('#download').height()*0.5 - 10;

			}
			$('.branding').css('top',offset);
			$('.branding .feature, .branding .panel').css('margin-top', -offset);
			$('.container').css('margin-top',offset);


			$('#feature').loopedSlider({
				container: '.feature-container',
				slides: '.application-list',
				containerClick: false, // Click container for next slide
				autoStart: 8500, // Set to positive number for auto start and interval time
				slidespeed: 1200, // Speed of slide animation
				restart: 8500
			}); 

		}
		 $(window).scroll(function () {
		 	var y = $(window).scrollTop();
		 	if (y >= $('.content:eq(0)').offset().top - 10) {
				$(".sub-nav").addClass('sub-nav-fixed');
			} else {
				$(".sub-nav").removeClass('sub-nav-fixed');
			}
		});
		
		$('img.size-thumbnail, img.size-medium, img.size-large, img.size-full').parent().addClass('popup');
		if (!$('a[href*=youtube.com/v/]').hasClass('popup')) $('a[href*=youtube.com/v/]').addClass('popup');
		$('a[href*=youtube.com/watch?v=]').addClass('popup').each(
			function(){
				var link = $(this).attr('href');
				link = 'http://www.youtube.com/v/' + link.substr(link.indexOf('watch?v=')+8,11) + '&rel=0&autoplay=1&hd=1&showinfo=0&iv_load_policy=3';
				$(this).attr('href',link);
			}
		);
		$.easy.popup();
	}
);