// ***************************************************
// * jQuery.dbh.components: jquery.dbh.FixIEBox.js
// * version: 1.0
// * © 2011 Derek Hughes
// ***************************************************

(function($) 
{
	$.fn.fixIEBox = function(options) 
	{
		settings = jQuery.extend(
		{
			force: false // Force fix even if IE7 fix js is detected
		}, options);
	
		// this browser not implements W3C implementation and (forced by setting or IE7 fix js detected)
		if (!jQuery.support.boxModel && (settings.force || typeof(IE7) != 'object')) 
		{
			// For each div
			return this.each(function() 
			{
				//Get the border size for this element
				borderH = parseInt($(this).css("border-left-width")) + parseInt($(this).css("border-right-width"));			
				borderV = parseInt($(this).css("border-top-width"))  + parseInt($(this).css("border-bottom-width"));			

				//Get the padding size for this element
				paddingH = parseInt($(this).css("padding-left")) + parseInt($(this).css("padding-right"));			
				paddingV = parseInt($(this).css("padding-top"))  + parseInt($(this).css("padding-bottom"));			

				// Get the width and height for this element
				width = $(this).css("width");				height = $(this).css("height");

//alert ("\r\nborderH: " + borderH + "\r\nborderV: " + borderV + "\r\npaddingH: " + paddingH + "\r\npaddingV: " + paddingV );

				// Calculate the new width and height				
				newWidth = width + borderH + paddingH;		newHeight = height + borderV + paddingV;

				// Set the new width and height
				$(this).css("width", newWidth + "px");				$(this).css("height", newHeight + "px");
			});
		}
		return this;
	}
})(jQuery);
