var DanHylander = {
	init: function () {
		DanHylander.addEndPiece();
		$(window).bind('load resize', DanHylander.adjustEndPieceHeight);
	},
	addEndPiece: function () {
		$('body').append('<div id="endpiece"/>');
		$('#endpiece')
			.css({
				'position': 'absolute',
				'left': 0,
				'right': 0,
				'height': 200
			});
	},
	adjustEndPieceHeight: function () {
		if ($('#container').height() > $('#dan').height()) {
			$('#dan').css({ 'top': 'auto', 'bottom': 0 });
		} else {
			$('#dan').css({ 'top': 20, 'bottom': 'auto' });
		}

		$('#endpiece').height(parseInt($('html').height() - $('body').height(), 10));
	}
};

$(DanHylander.init);
