$(function() {
	function showPage()
	{
		var loadedImages = 0;
		
		function show()
		{
			if (loadedImages == 3) {
				$("#ajaxloader").remove();
				$("#content").fadeTo(1000, 1);
			}
		}
		
		$("<img>").load(function(){
			loadedImages++;
			show();
		}).attr("src", "img/loveLifeLogo.gif");		
		$("<img>").load(function(){
			loadedImages++;
			show();
		}).attr("src", "img/philospohyImg.gif");		
		$("<img>").load(function(){
			loadedImages++;
			show();
		}).attr("src", "img/titleImg.gif");		
	}

	$("#content").fadeTo(0, 0);
	$("<img>").load(function(){
		showPage();
	}).attr("src", "img/ajax-loader.gif");
	$("#ajaxloader").show();
	
	
	var $container = $("#container");
	var containerHeight = $container.outerHeight();
	var containerTop = 0;
	var windowHeight;
	
	function pageVerticalCenter()
	{
		windowHeight = $(window).height();
		containerTop = (windowHeight - containerHeight)/2
		if (containerTop < 0) containerTop = 0;
		$container.css("margin-top", containerTop + "px");
	}
	
	pageVerticalCenter();
	
	var doCenter = false;
	$(window).resize(function(){ 
		if (doCenter !== false) clearTimeout(doCenter); 
		doCenter = setTimeout(function(){
			pageVerticalCenter();
		}, 200);
	}); 
	
});