
$(document).ready(function() {
	function center(target,loaded) {
		var offsetx = 0;
		var ctop = $(window).height()/2-$("#"+target).height()/2;
		ctop=0;
		var cleft = $(window).width()/2-$("#"+target).width()/2;
		//if(ctop <= 0) ctop =0;
		if(cleft <= offsetx) cleft = offsetx;
		if(!loaded) {
			$("#"+target).css({left: cleft});
			$(window).resize(function() { center(target,!loaded); });
			//$('#footer').css({left: cleft});
			}
			else
			{
			$("#"+target).stop();
			$("#"+target).animate({left: cleft}, 200, 'linear');
			//$('#footer').animate({left: cleft}, 200, 'linear');
			}
		/* POSITIONO IL FOOTER */
		//('#footer').css("top",$(window).height()-23);
		
		//$("#main_container").height($(window).height()-50);
		
		}

	center("main_container");
	center("homepage_content");
	center("footer");

}); 
