$().ready(function() {
		var minHeight = $('.sidebar').height();
		var fn = function() {
			var height = $('body').height();
			height -= $('.header').outerHeight(true);
			height -= $('.footer-wrapper').outerHeight(true);
			height -= $('.sidebar').outerHeight(true) - $('.sidebar').height();
			if (minHeight <= height && height + ($('.sidebar').outerHeight() - $('.sidebar').height()) > $('.content').outerHeight() && (height < $('.sidebar').height() || $('body').height() - $('.footer-wrapper').offset().top - $('.sidebar').outerHeight() != 0)) {
				$('.sidebar').height(height);
			} else if (height < minHeight && height + ($('.sidebar').outerHeight() - $('.sidebar').height()) > $('.content').outerHeight()) {
				$('.sidebar').height(minHeight);
			}
		}
		$(window).resize(fn);
		fn();
		
		/* fix sitemap images(menu-5) */
		$('.menu-5 .menu > .menu-item:first-child').css({'border': 'none' , 'background-image': 'url(/wp-content/themes/custom/image/sitemap-level1-top.png)', 'background-position': '0px 11px'});
		$('.menu-5 .menu > .menu-item:last-child').css({'border': 'none' , 'background-image': 'url(/wp-content/themes/custom/image/sitemap-level1-bottom.png)', 'background-position': '0px 0px'});
		$('.menu-5 .sub-menu > .menu-item:last-child').css({'border': 'none' , 'background-image': 'url(/wp-content/themes/custom/image/sitemap-level2-bottom.png)', 'background-position': '0px 0px', 'padding-bottom': '0px'});
		
		/*quiz warning if not all fields filled out*/
		$('.quiz form').submit(function() {
			var names = {};
			$(this).find('input:radio').each(function() {
				names[$(this).attr('name')] = true;
			});
			var count = 0;
			$.each(names, function() {
   			count++;
   		});
   		if($(this).find('input:radio:checked').length == count) {
  			return true;
   		}
   		alert('Vælg en svar mulighed til hver spørgsmål');
			return false;
		});
	}
);
