$(function(){
	// DOM initialization
	function centerObjectsHorizontallyOnScreen()
	{
		objects = new Array ( "#wrapper", "#shadow", "#logo", "#body-fade" );
		
		$.each(objects, function(k,v)
		{
			if ( $(window).width() < 1000 )
			{
				$(v).css({
					'left' : '10px'
				});
				$("#shadow").hide();
			} else {
				$("#shadow").show();
				$(v).css({
					'left' : ( ( $(window).width() / 2 ) - ( $(v).width() / 2 ) ) + 'px'
				});
			}
			if ( $(v).css("display") == "none" )
			{
				$(v).hide();
				$(v).show();
			}
		});
	}
	function scaleShadowsVerticallyOnScreen()
	{
		shadows = new Array ( "#shadow" );
		
		$.each(shadows, function(k,v)
		{
			$(v).css({
				'height' : ( $("#wrapper").height() + 2 ) + 'px'
			});
			if ( $(v).height() > 600 )
				$("#body-fade").show();
			else
				$("#body-fade").hide();
		});
		$("#body-fade").css({
			"top" : ( $("#wrapper").offset().top + $("#wrapper").height() - 50 ) + 'px'
		});
	}
	// Bindings
	$(window).resize(function()
	{
		centerObjectsHorizontallyOnScreen();
		scaleShadowsVerticallyOnScreen();
	});
	var centerChecker = null;
	function initializeCenterChecker()
	{
		centerChecker = setInterval(function(){
			$(window).resize();
		},500);
	}
	function stopCenterChecker()
	{
		clearInterval ( centerChecker );
		centerChecker = null;
	}
	// Main
	centerObjectsHorizontallyOnScreen();
	scaleShadowsVerticallyOnScreen();
	initializeCenterChecker();
});
