$(document).ready(function() {
	var wi = $(window).height();
	var d = $(document).height();
	var minH = 80;

	resize = function(w) {
		var o = $('#footwrap').offset().top;
		var f = $('#footwrap').height();	
		if (w >= wi) {
			if (o + f > w) {
				if (o + minH >= w) {
					$('#footwrap').css('height', minH +'px');
				} else {
					$('#footwrap').css('height', w-o +'px');
				}
			} else {
				$('#footwrap').css('height',f+(w-f-o)+'px');
			}
		}
	};
	resize(wi);
	
	$(window).resize(function() {
		var wn = $(window).height();
		resize(wn);
	});

	var viewlink = '<a href="javascript:displayBib()">View Full Bibliography</a> &#8675;';

	var hidelink = '<a href="javascript:hideBib()">Hide Full Bibliography</a> &#8673; ';

	displayBib = function() {
		$('.bibswitch').html(hidelink);
		$('#biblio').fadeIn('slow').slideDown('slow');
	};
	
	hideBib = function() {
		$('.bibswitch').html(viewlink);
		$('#biblio').fadeOut('slow').slideUp('slow');	
	}

	$('#biblio').before('<p class="bibswitch">'+ viewlink+'</p>');
	$('#biblio').append('<p class="bibswitch">'+ viewlink+'</p>');	
});
