/*
	jQuery Fit to Width v0.1
	This is only applicable for elements with 'display' set to 'block' or 'inline-block'.
	Copyright (c) 2010 Chris M. Sissons
	This plugin available for use in all personal or commercial projects.
*/

jQuery.fn.fitToWidth = function() {

	return this.each(function() {
		var el = jQuery(this);
		el.before('<' + this.tagName + ' style="height:0;">' + this.tagName + '</' + this.tagName + '>'); // Insert a sibling test element before the element.
		var naturalWidth = el.prev().width(); // Get dynamic width of test element.
		el.prev().remove(); // Remove test element.
		el.width(naturalWidth); // Resize element to available width.
	});
	
};

