// This function initiates when body has fully loaded
$(document).ready(function() {
	
	setEqualHeightOnStructureElements();
	
/*	if ($('#serviceTeaser').length != 0) {
		setequalHeightForServiceTeaser($('#serviceTeaser > ul > li'));
	}
	*/

	//Make the whole menu cell clickable
	$('#subMenu li').click(function(event) {
		window.location.href = $('a', this).attr('href');
	});
  
	//Expand/collapse (article) list nodes
	initExpandMenu();


});

// Fix equal heights on column structures
function setEqualHeightOnStructureElements() {
	if ($('#aside').height() > $('#mainColumn').height()) {
		$('#mainColumn').height($('#aside').height());
	}
	
	if ($('#subMenu').length != 0) {
		if ($('#subMenu').height() > $('#mainColumn').height()) {
			$('#mainColumn').height($('#subMenu').height());
		}
	}
}

// Fix equal heights on serviceTeaser
function setequalHeightForServiceTeaser(service) {
	var tallest = 0;
	service.each(function() {
		var thisHeight = $(this).height();
		if(thisHeight > tallest) {
			tallest = thisHeight;
		}
	});
	service.height(tallest);
}

// Opens the print dialog
function startPrintDialog() {
	window.print();
}

function initExpandMenu() {
	$('.expandMenu ul').not('#expandYear ul').hide();
	$('.expandMenu li a').click(
		function() {
			$(this).next().toggle('fast');
		}
	);
}

