$(document).ready(function() {
	
	$('body').addClass('js-enabled');
	
	$('#date').datepicker();
	
	$('#main .section .inner:not(.no-collapse)').each(function() {
		$(this).wrap('<div class="collapser" />');
	});
	
	$('#main h2 a').click(function(e) {
		e.preventDefault();
		
		var $inner = $(this).parents('.section').find('.inner'),
				$collapser = $inner.parent('.collapser');
		
		if($collapser.hasClass('expanded')) {
			$collapser.animate({'height':0}, 300, function() {
				$(this).removeClass('expanded');
			});
		} else {
			$collapser.animate({'height':$inner.outerHeight()+'px'}, 300, function() {
				$(this).addClass('expanded');
			});
		}
		
	});
		
		$(window).resize(function() {
			$('#main .section .expanded .inner').each(function() {
				var theight = $(this).outerHeight(),
						$collapser = $(this).parent('.collapser');
				if($collapser.height() != theight) {
					$collapser.height(theight);
				}
			});
		});
		
		var timer = setTimeout(function() {
			$('#contact h2 a').trigger('click');
		}, 1000);
		
	
});
