function pageResize () {
	
	/**
	 * Resizes the page to fit the width of the avatar list.
	 */
	
	var pageWidth = $('body').css('width').replace('px', '');
	
	if (pageWidth == 'auto') {
		
		pageWidth = document.body.clientWidth - 30;
		
	}
	
	if (pageWidth < 1024) pageWidth = 1024;
	
	var numAvatars = Math.floor((pageWidth - 140) / 134) * 134;
	
	$('#container').css('width', numAvatars + 'px');
	
	$('#avatar-box').css('margin-left', numAvatars / 2 - 372);
	
	$('#footer').css('width', numAvatars + 60 + 'px');
	
	if (numAvatars >= 7 * 134) {
		
		$('#download').removeClass('download').addClass('download-wide');
		
	} else {
		
		$('#download').removeClass('download-wide').addClass('download');
		
	}
	
}

$(document).ready(function() {
	
	pageResize();
	
	/**
	 * A bit flawed, if this is commented out it was obviously never fixed.
	 */
	$(window).resize(function() { pageResize(); });
	
});