$(document).ready(function() {
	
	$('.trigger').click(function() {

		//$('.trigger').removeClass('on');

		var min_height = 50;
		var clicked_item = $(this).parent();
		
		if($(this).hasClass('on')) {

			$(this).removeClass('on');
			$('.accordion-wrap').animate({ height: min_height }, 250);
			
		} else {

			$('.trigger').removeClass('on');
			$('.accordion-wrap').animate({ height: min_height }, 250);

			$(this).addClass('on');
			
			$(this).parent().animate({ height: $(this).next().height() }, 250, function() {

				var target_offset = clicked_item.position().top - 22;
	
				$('html, body').animate({
					scrollTop: target_offset
				}, 400);
			});
		}	
	 });

	// LIGHTBOX
	$(function() {
		$('#lightbox-gallery a').lightBox();
	});

	


	if ($(window).width() <= 480) {
	
		var container = document.getElementById('page-container');
		var video_container = document.getElementById('video-container');
		
		container.removeChild(video_container);
	
		$('#content-container').delay(300).fadeIn(2000);
		
	} else {

		$('#video-container').delay(3000).fadeOut(1000);
		$('#content-container').delay(4000);
	
		$(window).resize(function() {
		
			size_video();
	
		});
	}
	
	$('#video-container').bind('ended', function() {
		$('#video-container').fadeOut(1000);
	});

	function size_video() {
	
		var window_width = $(window).width();
	
		var video_max_width = 1920;
		var video_width = (window_width > video_max_width) ? video_max_width : Math.round(window_width);
		var video_height = ( video_width / 1920 ) * 1080;
	
	if(window_width < video_max_width) {
	
		$('#animate').width(video_width).height(video_height).css({ 'top': 0, 'margin-left': 0, 'margin-right': 0 });
	
	} else {
	
	// Begin Positioning Video Center
	var padding = (window_width - video_width) * 0.5;
	
		$('#animate').width(video_width).height(video_height).css({ 'margin-left': padding, 'margin-right': padding });
	}
}
});

