jQuery(function() {

	// IMAGE HIGHLIGHT
	$('.highlight').hover(
		function () { $(this).css('backgroundPosition','0 -' + $(this).height() + 'px'); },
		function () { $(this).css('backgroundPosition','0 0'); }
	);
});

var display_state = false;
var animating = false;

function display_content () {

	if (!animating) {
		
		animating = true;
		
		if (!display_state) {
		
			$('#header_top').fadeOut();
			$('#header_bottom').fadeOut(function () {
			
				$('#display').fadeIn();
				$('#header_top').html('');
				$('#header_bottom').html('');
				
				$('#display_link').addClass('d');
				$('#about_link').addClass('r w');
				
				display_state = true;
				animating = false;
			});		
			
		} else {
		
			// RANDOMIZE ARRAY
			var shuffle = [];
			while (words.length) shuffle.push(words.splice(Math.random() * words.length, 1));
			while (shuffle.length) words.push(shuffle.pop());
			
			$('#display').fadeOut(function () {
				
				$('#display_link').removeClass('d');
				$('#about_link').removeClass('r w');
				
				$('#phrase').fadeOut(function () {
				
					for (var i = 0; i < words.length; i++) {
					
						if (i < 5) $('#header_top').append(words[i] + '<br />');
						if (i == 5) $('#phrase').html('We ' + words[i] + ' stuff.');
						if (i > 5) $('#header_bottom').append(words[i] + '<br />');
					}
					
					$('#header_top').fadeIn();
					$('#header_bottom').fadeIn();
					$('#phrase').fadeIn();
					
					display_state = false;
					animating = false;
				});
			});
		}
	}
}

