$(function() {
	var freeHeight = $('body').height() - $('#title').height() - $('#picture').height() - $('#disclaimer').height(), freeWidth = $('body').width();
	var textHeight = $('#text').height(), textWidth = $('#text :first-child').width() * 1.05;
	var proportionHeight = freeHeight / textHeight;
	var proportionWidth = freeWidth / textWidth;
	
	textSize = Math.floor(Math.min(proportionHeight, proportionWidth));
	
	$('#picture').css('height', '1px').css('width', '1px').animate({
		height: 338,
		width: 273
	}, 2000, 'easeOutQuad');
	$('#text').animate({
		fontSize: textSize + 'em'
	}, 2000, 'easeOutQuad', function() {
		interval = setInterval(doTheDance, 250);
	});
});

var number = 0;
function doTheDance() {
	document.title = messages[number];
	if (!messages[++number]) {
		clearInterval(interval);
	}
}
