/**
 * #content-container must always be at least as tall as #nav2 if layout type is medium or large.
 * Check if #nav2 is taller than #content-container, if yes, increase #content-container height to match
 */
adjustColumnHeight = function () {
	// reset container height
		$('#content-container').css('height', 'auto');
	
	if ($('body').is('layout-small')) {
		// resetting height to auto is enough for small layout, just return now
			return;
	}
	
	if ($('#content-container').height() < $('#nav2').height()) {
		$('#content-container').height($('#nav2').height()+1); // give it 1 extra pixel to make sure
	}
};
	
init = function () {
	// Initiate ARIA navigation (for browsers that support ARIA)
		//$('#nav1, #tools').managefocus('a',{role:'menu'}); // not working for tools
	
	
	// Init secondary nav if present
		nav2Options = {
			topLevelCanToggle    : true,
			supportCSSImgReplace : true,
			clearPixelImg        : '/assets/images/ui/displacement.png'
		};
		$('#nav2 .site-section').exmenu('init', nav2Options);
		if (typeof expandNav2To != 'undefined') {
			$('#nav2 .site-section').exmenu('setCurrent', expandNav2To);
		}
		$('#nav2').click(adjustColumnHeight); // adjust after nav2 expanded/collapsed
		
	// Run once immediately
		adjustColumnHeight();
	
	// Pack up services lists
		baseShortListOptions = {
			howShort : 3,
			toggleShowText : 'More',
			toggleHideText : 'Less'
		}
		shortListOptions = baseShortListOptions;
		shortListOptions.toggleShowTitle = 'Show more services';
		shortListOptions.toggleHideTitle = 'Show less services';
		
		$('body').not('.page-home').find('#services ul').shorterList(shortListOptions);
		
		shortListOptions.howShort = 4; // Show 4 services on the homepage
		$('body.page-home').find('#services ul').shorterList(shortListOptions);
		
		shortListOptions = baseShortListOptions;
		shortListOptions.howShort = 6;
		shortListOptions.toggleShowTitle = 'Show more links';
		shortListOptions.toggleHideTitle = 'Show less links';
		$('body.page-home .in-your-region ul').shorterList(shortListOptions);
		
		
	// lightbox for survey/poll
		$('#poll a').click(function(eventObj) {
			GB_show(
				'Satisfaction survey',
				this.href,
				800, 1000,
				canShrink=true,
				closeChallenge='Close the survey? \nIf you choose to take '
					+'the survey later, you will need to start from the '
					+'beginning again'
			);
			return false;
        });
		
	
	// Pack up announcement list
		$('.previous.announcements').shorterList({
			howShort : 10,
			toggleShowTitle : 'Show all announcements',
			toggleHideTitle : 'Show less announcements',
			useSimpleAnimation : true // this list is too long for the complex animation
		});
		
	// Run linkedUp on any cluster page lists of links
		$('.pagetype-subject-home .index li p').linkedUp();
	
	// Init collapsable lists for My community page
		$('#towns-and-regions').exmenu('init', nav2Options);
};