// Init various items
jQuery(function($) { 
	// A hook for CSS if JS is enabled
	$('body').addClass('jsEnabled');
	
	// Setup toggler for the Publications collapsible menu
	$('.collapsible h3 a').click(function(){
		var box = $(this).parents('.box');
		box.find('ul').slideToggle('fast', function(){
			box.toggleClass('expanded');
			setScrollbars();
		});
		if (!box.is('.expanded')){
			box.siblings('.box').find('ul').slideUp('fast', function(){
				$(this).parents('.box').removeClass('expanded');
				$(this).removeClass('withScrollbars');
			});		
		}
		return false;
	});

	// Set scrollbars for the box if it's height is more than X.
	setScrollbars = function(){
		var box = $('.collapsible .expanded').each(function(){
			if ($(this).height() > 400){
				$(this).find('ul').addClass('withScrollbars');
			}
		});
	}
	
	// Initial scrollbars setup, for the Publications homepage.
	setScrollbars();

});
