jQuery.noConflict();
(function($) {
	$.fn.autoMargin = function() {
		// Calculate and assign new line-height
		function adjustTopMargin(container){
			var pxHeight = parseInt($(container).height());
			// Enforce minimum line-height
			var newTopMargin = -pxHeight - 35;
			$("#content-outer").css('margin-top', newTopMargin);
			
			var pxHeightContent = parseInt($("#content").height());
			var pxHeightSubContent = parseInt($("#bottom-area").height());
			var pxHeightNav = parseInt($("#nav").height());
	
			if( pxHeight > pxHeightContent ) {
				pxHeightSubContent = -pxHeightSubContent + (pxHeight/100);
				$("#content").css('height', pxHeightNav - 20);
			} else if( pxHeight < pxHeightContent ) {
				pxHeightSubContent = -pxHeightSubContent - 19;
			}
			
		$("#bottom-area").css('margin-top', pxHeightSubContent);
		}
		this.each(function(){
				var container = this;
				adjustTopMargin(container);
				// Re-adjust when window width is changed
				$(window).bind('resize', function(){
					adjustTopMargin(container);
				});
				// Re-adjust when font size changes
				$.jqem.bind(function() {
					adjustTopMargin(container);
				});
			});
		return this;
	};
})(jQuery);

jQuery(function(){
	jQuery('#nav').autoMargin();
});

