var currentItem = 1;
var previousItem = 1;
$(window).load(function(){
	$('#content div.flashing').removeClass('loading');
	$('#content div.flashing p').css({
		'visibility':'visible',
		'display':'none'
	});
	var count = $('#content div.flashing p').length;
	currentItem = Math.floor(Math.random()*count)+1;
	$("#content div.flashing p:nth-child("+currentItem+")").show();
	setInterval(function(){
		previousItem = currentItem;
		while(previousItem == currentItem) currentItem = Math.floor(Math.random()*count)+1;
		$("#content div.flashing p:nth-child("+previousItem+")").fadeOut(1000,function(){
			$("#content div.flashing p:nth-child("+currentItem+")").fadeIn(1000);
		});
	},5000);
});
$(document).ready(function(){
	initHeight();
});
$(window).resize(function(){
	initHeight();
});


function initHeight(){
	
	var bg = $('div.page-bg');
	var page = $('#page');
	bg.css('height','100%');
	if(bg.height() < page.height()) bg.height(page.height());
}