(function($) {
	$.fn.headerfix = function() {
			
		var padBeforeAndAfterLineBreak = function(){
			var elements = this.find('cufon');
			
			var padding = '10px';
			
			// Loop through the cufon elements to find the left-most
			var min = Infinity;
			var cur = 0;
			elements.each(function(){
				cur = $(this).position().left;
				if(cur < min) {
					min = cur;
				}
			});
			
			// Loop through again and add padding to the left-most elements (excluding the first if there is only one line of text)
			elements.each(function(index,item){
				if($(this).position().left == min && index != 0) {
					$(this).addClass('first-in-line');
					$(this).prev().addClass('last-in-line');
				}
			});
			
			// Add padding on the last element
			this.find('cufon:last').css('padding-right',padding);
		};

		return this.each(function() {
			padBeforeAndAfterLineBreak.apply($(this));
		});
	};
})(jQuery);
